import java.io.*;
import java.util.*;
public class Main {
    public static void main(String args[]) {
        Scanner in=new Scanner(System.in);
         String n=in.next();
         int sum=0;
         for(int i=0;i<n.length();i++){
            int x=Character.getNumericValue(n.charAt(i));
            sum=(sum+x)%9;
         }
         if(sum%9==0){
            System.out.println("Yes");
         }
         else
            System.out.println("No");
    }
}
class scan
{
    public static BufferedReader reader;
    public static StringTokenizer token;

    scan(InputStream str)
    {
        reader=new BufferedReader(new InputStreamReader(str));
        token=null;
    }

    static int nextInt()
    {
        while(token==null||!token.hasMoreTokens())
        {
            try { token=new StringTokenizer(reader.readLine());   }
            catch(IOException e){  throw new RuntimeException(e); }
        }
        return Integer.parseInt(token.nextToken());
    }

    static long nextLong()
    {
        while(token==null||!token.hasMoreTokens())
        {
            try { token=new StringTokenizer(reader.readLine());   }
            catch(IOException e){  throw new RuntimeException(e); }
        }
        return Long.parseLong(token.nextToken());
    }

    static String next()
    {
        while(token==null||!token.hasMoreTokens())
        {
            try { token=new StringTokenizer(reader.readLine());   }
            catch(IOException e){  throw new RuntimeException(e); }
        }
        return token.nextToken();
    }

} import java.io.*; io.* java import java.util.*; util.* java public class Main {
    public static void main(String args[]) {
        Scanner in=new Scanner(System.in);
         String n=in.next();
         int sum=0;
         for(int i=0;i<n.length();i++){
            int x=Character.getNumericValue(n.charAt(i));
            sum=(sum+x)%9;
         }
         if(sum%9==0){
            System.out.println("Yes");
         }
         else
            System.out.println("No");
    }
} Main public static void main(String args[]) {
        Scanner in=new Scanner(System.in);
         String n=in.next();
         int sum=0;
         for(int i=0;i<n.length();i++){
            int x=Character.getNumericValue(n.charAt(i));
            sum=(sum+x)%9;
         }
         if(sum%9==0){
            System.out.println("Yes");
         }
         else
            System.out.println("No");
    } main {
        Scanner in=new Scanner(System.in);
         String n=in.next();
         int sum=0;
         for(int i=0;i<n.length();i++){
            int x=Character.getNumericValue(n.charAt(i));
            sum=(sum+x)%9;
         }
         if(sum%9==0){
            System.out.println("Yes");
         }
         else
            System.out.println("No");
    } Scanner in=new Scanner(System.in); in new Scanner(System.in) String n=in.next(); n in.next() in.next in int sum=0; sum 0 for(int i=0;i<n.length();i++){
            int x=Character.getNumericValue(n.charAt(i));
            sum=(sum+x)%9;
         } int i=0; int i=0; i 0 i<n.length() i n.length() n.length n i++ i++ i {
            int x=Character.getNumericValue(n.charAt(i));
            sum=(sum+x)%9;
         } {
            int x=Character.getNumericValue(n.charAt(i));
            sum=(sum+x)%9;
         } int x=Character.getNumericValue(n.charAt(i)); x Character.getNumericValue(n.charAt(i)) Character.getNumericValue Character n.charAt(i) n.charAt n i sum=(sum+x)%9 sum (sum+x)%9 (sum+x) sum x 9 if(sum%9==0){
            System.out.println("Yes");
         }
         else
            System.out.println("No"); sum%9==0 sum%9 sum 9 0 {
            System.out.println("Yes");
         } System.out.println("Yes") System.out.println System.out System System.out "Yes" System.out.println("No") System.out.println System.out System System.out "No" String args[] args class scan
{
    public static BufferedReader reader;
    public static StringTokenizer token;

    scan(InputStream str)
    {
        reader=new BufferedReader(new InputStreamReader(str));
        token=null;
    }

    static int nextInt()
    {
        while(token==null||!token.hasMoreTokens())
        {
            try { token=new StringTokenizer(reader.readLine());   }
            catch(IOException e){  throw new RuntimeException(e); }
        }
        return Integer.parseInt(token.nextToken());
    }

    static long nextLong()
    {
        while(token==null||!token.hasMoreTokens())
        {
            try { token=new StringTokenizer(reader.readLine());   }
            catch(IOException e){  throw new RuntimeException(e); }
        }
        return Long.parseLong(token.nextToken());
    }

    static String next()
    {
        while(token==null||!token.hasMoreTokens())
        {
            try { token=new StringTokenizer(reader.readLine());   }
            catch(IOException e){  throw new RuntimeException(e); }
        }
        return token.nextToken();
    }

} scan public static BufferedReader reader; reader public static StringTokenizer token; token scan(InputStream str)
    {
        reader=new BufferedReader(new InputStreamReader(str));
        token=null;
    } scan {
        reader=new BufferedReader(new InputStreamReader(str));
        token=null;
    } reader=new BufferedReader(new InputStreamReader(str)) reader new BufferedReader(new InputStreamReader(str)) token=null token null InputStream str str static int nextInt()
    {
        while(token==null||!token.hasMoreTokens())
        {
            try { token=new StringTokenizer(reader.readLine());   }
            catch(IOException e){  throw new RuntimeException(e); }
        }
        return Integer.parseInt(token.nextToken());
    } nextInt {
        while(token==null||!token.hasMoreTokens())
        {
            try { token=new StringTokenizer(reader.readLine());   }
            catch(IOException e){  throw new RuntimeException(e); }
        }
        return Integer.parseInt(token.nextToken());
    } while(token==null||!token.hasMoreTokens())
        {
            try { token=new StringTokenizer(reader.readLine());   }
            catch(IOException e){  throw new RuntimeException(e); }
        } token==null||!token.hasMoreTokens() token==null token null !token.hasMoreTokens() token.hasMoreTokens() token.hasMoreTokens token {
            try { token=new StringTokenizer(reader.readLine());   }
            catch(IOException e){  throw new RuntimeException(e); }
        } try { token=new StringTokenizer(reader.readLine());   }
            catch(IOException e){  throw new RuntimeException(e); } catch(IOException e){  throw new RuntimeException(e); } IOException e {  throw new RuntimeException(e); } throw new RuntimeException(e); new RuntimeException(e) { token=new StringTokenizer(reader.readLine());   } token=new StringTokenizer(reader.readLine()) token new StringTokenizer(reader.readLine()) return Integer.parseInt(token.nextToken()); Integer.parseInt(token.nextToken()) Integer.parseInt Integer token.nextToken() token.nextToken token static long nextLong()
    {
        while(token==null||!token.hasMoreTokens())
        {
            try { token=new StringTokenizer(reader.readLine());   }
            catch(IOException e){  throw new RuntimeException(e); }
        }
        return Long.parseLong(token.nextToken());
    } nextLong {
        while(token==null||!token.hasMoreTokens())
        {
            try { token=new StringTokenizer(reader.readLine());   }
            catch(IOException e){  throw new RuntimeException(e); }
        }
        return Long.parseLong(token.nextToken());
    } while(token==null||!token.hasMoreTokens())
        {
            try { token=new StringTokenizer(reader.readLine());   }
            catch(IOException e){  throw new RuntimeException(e); }
        } token==null||!token.hasMoreTokens() token==null token null !token.hasMoreTokens() token.hasMoreTokens() token.hasMoreTokens token {
            try { token=new StringTokenizer(reader.readLine());   }
            catch(IOException e){  throw new RuntimeException(e); }
        } try { token=new StringTokenizer(reader.readLine());   }
            catch(IOException e){  throw new RuntimeException(e); } catch(IOException e){  throw new RuntimeException(e); } IOException e {  throw new RuntimeException(e); } throw new RuntimeException(e); new RuntimeException(e) { token=new StringTokenizer(reader.readLine());   } token=new StringTokenizer(reader.readLine()) token new StringTokenizer(reader.readLine()) return Long.parseLong(token.nextToken()); Long.parseLong(token.nextToken()) Long.parseLong Long token.nextToken() token.nextToken token static String next()
    {
        while(token==null||!token.hasMoreTokens())
        {
            try { token=new StringTokenizer(reader.readLine());   }
            catch(IOException e){  throw new RuntimeException(e); }
        }
        return token.nextToken();
    } next {
        while(token==null||!token.hasMoreTokens())
        {
            try { token=new StringTokenizer(reader.readLine());   }
            catch(IOException e){  throw new RuntimeException(e); }
        }
        return token.nextToken();
    } while(token==null||!token.hasMoreTokens())
        {
            try { token=new StringTokenizer(reader.readLine());   }
            catch(IOException e){  throw new RuntimeException(e); }
        } token==null||!token.hasMoreTokens() token==null token null !token.hasMoreTokens() token.hasMoreTokens() token.hasMoreTokens token {
            try { token=new StringTokenizer(reader.readLine());   }
            catch(IOException e){  throw new RuntimeException(e); }
        } try { token=new StringTokenizer(reader.readLine());   }
            catch(IOException e){  throw new RuntimeException(e); } catch(IOException e){  throw new RuntimeException(e); } IOException e {  throw new RuntimeException(e); } throw new RuntimeException(e); new RuntimeException(e) { token=new StringTokenizer(reader.readLine());   } token=new StringTokenizer(reader.readLine()) token new StringTokenizer(reader.readLine()) return token.nextToken(); token.nextToken() token.nextToken token public class Main {
    public static void main(String args[]) {
        Scanner in=new Scanner(System.in);
         String n=in.next();
         int sum=0;
         for(int i=0;i<n.length();i++){
            int x=Character.getNumericValue(n.charAt(i));
            sum=(sum+x)%9;
         }
         if(sum%9==0){
            System.out.println("Yes");
         }
         else
            System.out.println("No");
    }
} public class Main {
    public static void main(String args[]) {
        Scanner in=new Scanner(System.in);
         String n=in.next();
         int sum=0;
         for(int i=0;i<n.length();i++){
            int x=Character.getNumericValue(n.charAt(i));
            sum=(sum+x)%9;
         }
         if(sum%9==0){
            System.out.println("Yes");
         }
         else
            System.out.println("No");
    }
} Main
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String args[]) {
        Scanner in=new Scanner(System.in);
         String n=in.next();
         int sum=0;
         for(int i=0;i<n.length();i++){
            int x=Character.getNumericValue(n.charAt(i));
            sum=(sum+x)%9;
         }
         if(sum%9==0){
            System.out.println("Yes");
         }
         else
            System.out.println("No");
    }
}
class scan
{
    public static BufferedReader reader;
    public static StringTokenizer token;

    scan(InputStream str)
    {
        reader=new BufferedReader(new InputStreamReader(str));
        token=null;
    }

    static int nextInt()
    {
        while(token==null||!token.hasMoreTokens())
        {
            try { token=new StringTokenizer(reader.readLine());   }
            catch(IOException e){  throw new RuntimeException(e); }
        }
        return Integer.parseInt(token.nextToken());
    }

    static long nextLong()
    {
        while(token==null||!token.hasMoreTokens())
        {
            try { token=new StringTokenizer(reader.readLine());   }
            catch(IOException e){  throw new RuntimeException(e); }
        }
        return Long.parseLong(token.nextToken());
    }

    static String next()
    {
        while(token==null||!token.hasMoreTokens())
        {
            try { token=new StringTokenizer(reader.readLine());   }
            catch(IOException e){  throw new RuntimeException(e); }
        }
        return token.nextToken();
    }

}