import java.util.*;
import java.io.*;
public class Main {

	static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
        
        public FastReader()
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        
        String next()
        {
            while(st==null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt()
        {
            return Integer.parseInt(next());
        }
        
        String nextLine()
        {
            String s = "";
            
            try
            {
                s = br.readLine();
            }
            catch(IOException e)
            {
                e.printStackTrace();
            }
            return s;
        }
    }
    
    public static void main(String[] args) throws java.lang.Exception
    {
        try
        {
            FastReader fr=new FastReader();
            
           String s=fr.nextLine();
            long sum=0;
           for(int i=0;i<s.length();i++) {
        	   sum+=Long.parseLong(String.valueOf(s.charAt(i)));
           }
            if(sum%9==0) {
            	System.out.println("Yes");
            }
            else {
            	System.out.println("No");
            }
            
            
        }
        catch(Exception e){}
        finally{}

	}

} import java.util.*; util.* java import java.io.*; io.* java public class Main {

	static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
        
        public FastReader()
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        
        String next()
        {
            while(st==null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt()
        {
            return Integer.parseInt(next());
        }
        
        String nextLine()
        {
            String s = "";
            
            try
            {
                s = br.readLine();
            }
            catch(IOException e)
            {
                e.printStackTrace();
            }
            return s;
        }
    }
    
    public static void main(String[] args) throws java.lang.Exception
    {
        try
        {
            FastReader fr=new FastReader();
            
           String s=fr.nextLine();
            long sum=0;
           for(int i=0;i<s.length();i++) {
        	   sum+=Long.parseLong(String.valueOf(s.charAt(i)));
           }
            if(sum%9==0) {
            	System.out.println("Yes");
            }
            else {
            	System.out.println("No");
            }
            
            
        }
        catch(Exception e){}
        finally{}

	}

} Main public static void main(String[] args) throws java.lang.Exception
    {
        try
        {
            FastReader fr=new FastReader();
            
           String s=fr.nextLine();
            long sum=0;
           for(int i=0;i<s.length();i++) {
        	   sum+=Long.parseLong(String.valueOf(s.charAt(i)));
           }
            if(sum%9==0) {
            	System.out.println("Yes");
            }
            else {
            	System.out.println("No");
            }
            
            
        }
        catch(Exception e){}
        finally{}

	} main {
        try
        {
            FastReader fr=new FastReader();
            
           String s=fr.nextLine();
            long sum=0;
           for(int i=0;i<s.length();i++) {
        	   sum+=Long.parseLong(String.valueOf(s.charAt(i)));
           }
            if(sum%9==0) {
            	System.out.println("Yes");
            }
            else {
            	System.out.println("No");
            }
            
            
        }
        catch(Exception e){}
        finally{}

	} try
        {
            FastReader fr=new FastReader();
            
           String s=fr.nextLine();
            long sum=0;
           for(int i=0;i<s.length();i++) {
        	   sum+=Long.parseLong(String.valueOf(s.charAt(i)));
           }
            if(sum%9==0) {
            	System.out.println("Yes");
            }
            else {
            	System.out.println("No");
            }
            
            
        }
        catch(Exception e){}
        finally{} catch(Exception e){} Exception e {} {} {
            FastReader fr=new FastReader();
            
           String s=fr.nextLine();
            long sum=0;
           for(int i=0;i<s.length();i++) {
        	   sum+=Long.parseLong(String.valueOf(s.charAt(i)));
           }
            if(sum%9==0) {
            	System.out.println("Yes");
            }
            else {
            	System.out.println("No");
            }
            
            
        } FastReader fr=new FastReader(); fr new FastReader() String s=fr.nextLine(); s fr.nextLine() fr.nextLine fr long sum=0; sum 0 for(int i=0;i<s.length();i++) {
        	   sum+=Long.parseLong(String.valueOf(s.charAt(i)));
           } int i=0; int i=0; i 0 i<s.length() i s.length() s.length s i++ i++ i {
        	   sum+=Long.parseLong(String.valueOf(s.charAt(i)));
           } {
        	   sum+=Long.parseLong(String.valueOf(s.charAt(i)));
           } sum+=Long.parseLong(String.valueOf(s.charAt(i))) sum Long.parseLong(String.valueOf(s.charAt(i))) Long.parseLong Long String.valueOf(s.charAt(i)) String.valueOf String s.charAt(i) s.charAt s i 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("No") System.out.println System.out System System.out "No" String[] args args static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
        
        public FastReader()
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        
        String next()
        {
            while(st==null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt()
        {
            return Integer.parseInt(next());
        }
        
        String nextLine()
        {
            String s = "";
            
            try
            {
                s = br.readLine();
            }
            catch(IOException e)
            {
                e.printStackTrace();
            }
            return s;
        }
    } FastReader BufferedReader br; br StringTokenizer st; st public FastReader()
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        } FastReader {
            br = new BufferedReader(new InputStreamReader(System.in));
        } br = new BufferedReader(new InputStreamReader(System.in)) br new BufferedReader(new InputStreamReader(System.in)) String next()
        {
            while(st==null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        } next {
            while(st==null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        } while(st==null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException e)
                {
                    e.printStackTrace();
                }
            } st==null || !st.hasMoreElements() st==null st null !st.hasMoreElements() st.hasMoreElements() st.hasMoreElements st {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException e)
                {
                    e.printStackTrace();
                }
            } try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException e)
                {
                    e.printStackTrace();
                } catch(IOException e)
                {
                    e.printStackTrace();
                } IOException e {
                    e.printStackTrace();
                } e.printStackTrace() e.printStackTrace e {
                    st = new StringTokenizer(br.readLine());
                } st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) return st.nextToken(); st.nextToken() st.nextToken st int nextInt()
        {
            return Integer.parseInt(next());
        } nextInt {
            return Integer.parseInt(next());
        } return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next String nextLine()
        {
            String s = "";
            
            try
            {
                s = br.readLine();
            }
            catch(IOException e)
            {
                e.printStackTrace();
            }
            return s;
        } nextLine {
            String s = "";
            
            try
            {
                s = br.readLine();
            }
            catch(IOException e)
            {
                e.printStackTrace();
            }
            return s;
        } String s = ""; s "" try
            {
                s = br.readLine();
            }
            catch(IOException e)
            {
                e.printStackTrace();
            } catch(IOException e)
            {
                e.printStackTrace();
            } IOException e {
                e.printStackTrace();
            } e.printStackTrace() e.printStackTrace e {
                s = br.readLine();
            } s = br.readLine() s br.readLine() br.readLine br return s; s public class Main {

	static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
        
        public FastReader()
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        
        String next()
        {
            while(st==null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt()
        {
            return Integer.parseInt(next());
        }
        
        String nextLine()
        {
            String s = "";
            
            try
            {
                s = br.readLine();
            }
            catch(IOException e)
            {
                e.printStackTrace();
            }
            return s;
        }
    }
    
    public static void main(String[] args) throws java.lang.Exception
    {
        try
        {
            FastReader fr=new FastReader();
            
           String s=fr.nextLine();
            long sum=0;
           for(int i=0;i<s.length();i++) {
        	   sum+=Long.parseLong(String.valueOf(s.charAt(i)));
           }
            if(sum%9==0) {
            	System.out.println("Yes");
            }
            else {
            	System.out.println("No");
            }
            
            
        }
        catch(Exception e){}
        finally{}

	}

} public class Main {

	static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
        
        public FastReader()
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        
        String next()
        {
            while(st==null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt()
        {
            return Integer.parseInt(next());
        }
        
        String nextLine()
        {
            String s = "";
            
            try
            {
                s = br.readLine();
            }
            catch(IOException e)
            {
                e.printStackTrace();
            }
            return s;
        }
    }
    
    public static void main(String[] args) throws java.lang.Exception
    {
        try
        {
            FastReader fr=new FastReader();
            
           String s=fr.nextLine();
            long sum=0;
           for(int i=0;i<s.length();i++) {
        	   sum+=Long.parseLong(String.valueOf(s.charAt(i)));
           }
            if(sum%9==0) {
            	System.out.println("Yes");
            }
            else {
            	System.out.println("No");
            }
            
            
        }
        catch(Exception e){}
        finally{}

	}

} Main
import java.util.*;
import java.io.*;
public class Main {

	static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
        
        public FastReader()
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        
        String next()
        {
            while(st==null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt()
        {
            return Integer.parseInt(next());
        }
        
        String nextLine()
        {
            String s = "";
            
            try
            {
                s = br.readLine();
            }
            catch(IOException e)
            {
                e.printStackTrace();
            }
            return s;
        }
    }
    
    public static void main(String[] args) throws java.lang.Exception
    {
        try
        {
            FastReader fr=new FastReader();
            
           String s=fr.nextLine();
            long sum=0;
           for(int i=0;i<s.length();i++) {
        	   sum+=Long.parseLong(String.valueOf(s.charAt(i)));
           }
            if(sum%9==0) {
            	System.out.println("Yes");
            }
            else {
            	System.out.println("No");
            }
            
            
        }
        catch(Exception e){}
        finally{}

	}

}
