import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;
import java.math.BigInteger; 
public class Main
{
     static Scanner sc=new Scanner(System.in);
    static PrintWriter out=new PrintWriter(System.out);
    static void pn(Object o)
     {
    out.println(o);
    out.flush();
    
    }
    static void p(Object o)
    {
    out.print(o);
    out.flush();
    }
    static void pni(Object o)
    {
    out.println(o);System.out.flush();
    }
        static int I() throws IOException
    { 
    return sc.nextInt();
    }
    static long L()throws IOException
    {
    return sc.nextLong();
    }
    static double D()throws IOException
    {
    return sc.nextDouble();
    }
    static String S()throws IOException
    {
    return sc.next();
        }
     static void process() throws IOException
     {
         String s=S();long k=0;
          for(int i=0;i<s.length();i++)
          {
             k=k+((int)s.charAt(i)-48);
            }
          if(k%9==0)
          {
              pn("Yes");
            }
            else
            {
                pn("No");
            }
        }
        public static void main(String[] args) throws IOException
{
   try
{
        process();
 }
catch(Exception e)
{
return;
}
}
             
         
       }
    import java.io.IOException; IOException java.io import java.io.PrintWriter; PrintWriter java.io import java.util.Scanner; Scanner java.util import java.math.BigInteger; BigInteger java.math public class Main
{
     static Scanner sc=new Scanner(System.in);
    static PrintWriter out=new PrintWriter(System.out);
    static void pn(Object o)
     {
    out.println(o);
    out.flush();
    
    }
    static void p(Object o)
    {
    out.print(o);
    out.flush();
    }
    static void pni(Object o)
    {
    out.println(o);System.out.flush();
    }
        static int I() throws IOException
    { 
    return sc.nextInt();
    }
    static long L()throws IOException
    {
    return sc.nextLong();
    }
    static double D()throws IOException
    {
    return sc.nextDouble();
    }
    static String S()throws IOException
    {
    return sc.next();
        }
     static void process() throws IOException
     {
         String s=S();long k=0;
          for(int i=0;i<s.length();i++)
          {
             k=k+((int)s.charAt(i)-48);
            }
          if(k%9==0)
          {
              pn("Yes");
            }
            else
            {
                pn("No");
            }
        }
        public static void main(String[] args) throws IOException
{
   try
{
        process();
 }
catch(Exception e)
{
return;
}
}
             
         
       } Main static Scanner sc=new Scanner(System.in); sc new Scanner(System.in) static PrintWriter out=new PrintWriter(System.out); out new PrintWriter(System.out) static void pn(Object o)
     {
    out.println(o);
    out.flush();
    
    } pn {
    out.println(o);
    out.flush();
    
    } out.println(o) out.println out o out.flush() out.flush out Object o o static void p(Object o)
    {
    out.print(o);
    out.flush();
    } p {
    out.print(o);
    out.flush();
    } out.print(o) out.print out o out.flush() out.flush out Object o o static void pni(Object o)
    {
    out.println(o);System.out.flush();
    } pni {
    out.println(o);System.out.flush();
    } out.println(o) out.println out o System.out.flush() System.out.flush System.out System System.out Object o o static int I() throws IOException
    { 
    return sc.nextInt();
    } I { 
    return sc.nextInt();
    } return sc.nextInt(); sc.nextInt() sc.nextInt sc static long L()throws IOException
    {
    return sc.nextLong();
    } L {
    return sc.nextLong();
    } return sc.nextLong(); sc.nextLong() sc.nextLong sc static double D()throws IOException
    {
    return sc.nextDouble();
    } D {
    return sc.nextDouble();
    } return sc.nextDouble(); sc.nextDouble() sc.nextDouble sc static String S()throws IOException
    {
    return sc.next();
        } S {
    return sc.next();
        } return sc.next(); sc.next() sc.next sc static void process() throws IOException
     {
         String s=S();long k=0;
          for(int i=0;i<s.length();i++)
          {
             k=k+((int)s.charAt(i)-48);
            }
          if(k%9==0)
          {
              pn("Yes");
            }
            else
            {
                pn("No");
            }
        } process {
         String s=S();long k=0;
          for(int i=0;i<s.length();i++)
          {
             k=k+((int)s.charAt(i)-48);
            }
          if(k%9==0)
          {
              pn("Yes");
            }
            else
            {
                pn("No");
            }
        } String s=S(); s S() S long k=0; k 0 for(int i=0;i<s.length();i++)
          {
             k=k+((int)s.charAt(i)-48);
            } int i=0; int i=0; i 0 i<s.length() i s.length() s.length s i++ i++ i {
             k=k+((int)s.charAt(i)-48);
            } {
             k=k+((int)s.charAt(i)-48);
            } k=k+((int)s.charAt(i)-48) k k+((int)s.charAt(i)-48) k ((int)s.charAt(i)-48) (int)s.charAt(i) s.charAt s i 48 if(k%9==0)
          {
              pn("Yes");
            }
            else
            {
                pn("No");
            } k%9==0 k%9 k 9 0 {
              pn("Yes");
            } pn("Yes") pn "Yes" {
                pn("No");
            } pn("No") pn "No" public static void main(String[] args) throws IOException
{
   try
{
        process();
 }
catch(Exception e)
{
return;
}
} main {
   try
{
        process();
 }
catch(Exception e)
{
return;
}
} try
{
        process();
 }
catch(Exception e)
{
return;
} catch(Exception e)
{
return;
} Exception e {
return;
} return; {
        process();
 } process() process String[] args args public class Main
{
     static Scanner sc=new Scanner(System.in);
    static PrintWriter out=new PrintWriter(System.out);
    static void pn(Object o)
     {
    out.println(o);
    out.flush();
    
    }
    static void p(Object o)
    {
    out.print(o);
    out.flush();
    }
    static void pni(Object o)
    {
    out.println(o);System.out.flush();
    }
        static int I() throws IOException
    { 
    return sc.nextInt();
    }
    static long L()throws IOException
    {
    return sc.nextLong();
    }
    static double D()throws IOException
    {
    return sc.nextDouble();
    }
    static String S()throws IOException
    {
    return sc.next();
        }
     static void process() throws IOException
     {
         String s=S();long k=0;
          for(int i=0;i<s.length();i++)
          {
             k=k+((int)s.charAt(i)-48);
            }
          if(k%9==0)
          {
              pn("Yes");
            }
            else
            {
                pn("No");
            }
        }
        public static void main(String[] args) throws IOException
{
   try
{
        process();
 }
catch(Exception e)
{
return;
}
}
             
         
       } public class Main
{
     static Scanner sc=new Scanner(System.in);
    static PrintWriter out=new PrintWriter(System.out);
    static void pn(Object o)
     {
    out.println(o);
    out.flush();
    
    }
    static void p(Object o)
    {
    out.print(o);
    out.flush();
    }
    static void pni(Object o)
    {
    out.println(o);System.out.flush();
    }
        static int I() throws IOException
    { 
    return sc.nextInt();
    }
    static long L()throws IOException
    {
    return sc.nextLong();
    }
    static double D()throws IOException
    {
    return sc.nextDouble();
    }
    static String S()throws IOException
    {
    return sc.next();
        }
     static void process() throws IOException
     {
         String s=S();long k=0;
          for(int i=0;i<s.length();i++)
          {
             k=k+((int)s.charAt(i)-48);
            }
          if(k%9==0)
          {
              pn("Yes");
            }
            else
            {
                pn("No");
            }
        }
        public static void main(String[] args) throws IOException
{
   try
{
        process();
 }
catch(Exception e)
{
return;
}
}
             
         
       } Main
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;
import java.math.BigInteger; 
public class Main
{
     static Scanner sc=new Scanner(System.in);
    static PrintWriter out=new PrintWriter(System.out);
    static void pn(Object o)
     {
    out.println(o);
    out.flush();
    
    }
    static void p(Object o)
    {
    out.print(o);
    out.flush();
    }
    static void pni(Object o)
    {
    out.println(o);System.out.flush();
    }
        static int I() throws IOException
    { 
    return sc.nextInt();
    }
    static long L()throws IOException
    {
    return sc.nextLong();
    }
    static double D()throws IOException
    {
    return sc.nextDouble();
    }
    static String S()throws IOException
    {
    return sc.next();
        }
     static void process() throws IOException
     {
         String s=S();long k=0;
          for(int i=0;i<s.length();i++)
          {
             k=k+((int)s.charAt(i)-48);
            }
          if(k%9==0)
          {
              pn("Yes");
            }
            else
            {
                pn("No");
            }
        }
        public static void main(String[] args) throws IOException
{
   try
{
        process();
 }
catch(Exception e)
{
return;
}
}
             
         
       }
   