//JAI BAJRANGBALI                                                                                                                                               
import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class Main
{
    public final static int d = 256; 
    static int MOD = 1000000007;
    static final float EPSILON = (float)0.01; 
    static final double PI = 3.1415926536;
    private static BufferedReader in = new BufferedReader (new InputStreamReader (System.in));
    private static BufferedWriter out = new BufferedWriter (new OutputStreamWriter (System.out));
    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()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        {
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
    static int searchRabinKarp(String pat, String txt) 
    { 
        int M = pat.length(); 
        int N = txt.length(); 
        int i, j; 
        int p = 0; // hash value for pattern 
        int t = 0; // hash value for txt 
        int h = 1 , cnt = 0; 
        int q = 3355439;         
        for (i = 0; i < M-1; i++) 
            h = (h*d)%q; 
        for (i = 0; i < M; i++) 
        { 
            p = (d*p + pat.charAt(i))%q; 
            t = (d*t + txt.charAt(i))%q; 
        } 
        for (i = 0; i <= N - M; i++) 
        {     
            if ( p == t ) 
            {                 
                for (j = 0; j < M; j++) 
                { 
                    if (txt.charAt(i+j) != pat.charAt(j)) 
                        break; 
                }                 
                if (j == M) 
                {//System.out.println("Pattern found at index " + i);
                    cnt++;
                } 
            } 
            if ( i < N-M ) 
            { 
                t = (d*(t - txt.charAt(i)*h) + txt.charAt(i+M))%q; 
                if (t < 0) 
                    t = (t + q); 
            } 
        } 
        return cnt;
    }
    static long gcd(long bigger , long smaller)
    {
            if (smaller == 0) 
                return bigger; 
            return gcd(smaller, bigger % smaller); 
    }
    static long lcm(long a, long b) 
    { 
        return (a*b)/gcd(a, b); 
    } 
    static long sumOfArray(long arr[])
    {
        long sum = 0;
        for(int i = 0 ; i < arr.length ; i++)
            sum += arr[i];
        return sum;
    }
    static boolean isPrime(long n) {
        if(n == 2)
            return true;
        else if(n == 1)
            return false;
        else if (n%2==0)
            return false;          
        for(long i=3;i<=Math.sqrt(n);i+=2) { 
            if(n%i==0) 
                return false; 
        } 
        return true; 
    }
    static long countDigit(long n) 
    { 
        return (long)Math.floor(Math.log10(n) + 1); 
    }
    static long sumOfDigits(long n) 
    { 
        long sum;        
        for (sum = 0; n > 0; sum += n % 10,n /= 10);   
        return sum; 
    }        
    static boolean isPalindrome(String str) 
    {   
        int i = 0, j = str.length() - 1; 
        while (i < j) { 
            if (str.charAt(i) != str.charAt(j)) 
                return false; 
            i++; 
            j--; 
        } 
        return true; 
    }      
    public static void main(String args[])
    {
        try{
            FastReader sc = new FastReader();
            int T = 1;//sc.nextInt();
            while(T-- > 0)
            {
                String str = sc.next();
                out.write(solve(str)+"\n"); 
            }
            try{
                out.flush();
            }catch(Exception e){
                System.out.print("");
            };
        }
        catch(Exception e){
            System.out.print("");
        }
    } 
    public static String solve(String str)
    {       
        long sum = 0;  
        for(int i = 0 ; i < str.length() ; i++)
        {
            sum += (str.charAt(i) - '0');
        }   
        if(sum%9 == 0)
            return "Yes";   
        return "No";
    }      
}    import java.util.*; util.* java import java.io.*; io.* java import java.math.BigInteger; BigInteger java.math public class Main
{
    public final static int d = 256; 
    static int MOD = 1000000007;
    static final float EPSILON = (float)0.01; 
    static final double PI = 3.1415926536;
    private static BufferedReader in = new BufferedReader (new InputStreamReader (System.in));
    private static BufferedWriter out = new BufferedWriter (new OutputStreamWriter (System.out));
    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()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        {
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
    static int searchRabinKarp(String pat, String txt) 
    { 
        int M = pat.length(); 
        int N = txt.length(); 
        int i, j; 
        int p = 0; // hash value for pattern 
        int t = 0; // hash value for txt 
        int h = 1 , cnt = 0; 
        int q = 3355439;         
        for (i = 0; i < M-1; i++) 
            h = (h*d)%q; 
        for (i = 0; i < M; i++) 
        { 
            p = (d*p + pat.charAt(i))%q; 
            t = (d*t + txt.charAt(i))%q; 
        } 
        for (i = 0; i <= N - M; i++) 
        {     
            if ( p == t ) 
            {                 
                for (j = 0; j < M; j++) 
                { 
                    if (txt.charAt(i+j) != pat.charAt(j)) 
                        break; 
                }                 
                if (j == M) 
                {//System.out.println("Pattern found at index " + i);
                    cnt++;
                } 
            } 
            if ( i < N-M ) 
            { 
                t = (d*(t - txt.charAt(i)*h) + txt.charAt(i+M))%q; 
                if (t < 0) 
                    t = (t + q); 
            } 
        } 
        return cnt;
    }
    static long gcd(long bigger , long smaller)
    {
            if (smaller == 0) 
                return bigger; 
            return gcd(smaller, bigger % smaller); 
    }
    static long lcm(long a, long b) 
    { 
        return (a*b)/gcd(a, b); 
    } 
    static long sumOfArray(long arr[])
    {
        long sum = 0;
        for(int i = 0 ; i < arr.length ; i++)
            sum += arr[i];
        return sum;
    }
    static boolean isPrime(long n) {
        if(n == 2)
            return true;
        else if(n == 1)
            return false;
        else if (n%2==0)
            return false;          
        for(long i=3;i<=Math.sqrt(n);i+=2) { 
            if(n%i==0) 
                return false; 
        } 
        return true; 
    }
    static long countDigit(long n) 
    { 
        return (long)Math.floor(Math.log10(n) + 1); 
    }
    static long sumOfDigits(long n) 
    { 
        long sum;        
        for (sum = 0; n > 0; sum += n % 10,n /= 10);   
        return sum; 
    }        
    static boolean isPalindrome(String str) 
    {   
        int i = 0, j = str.length() - 1; 
        while (i < j) { 
            if (str.charAt(i) != str.charAt(j)) 
                return false; 
            i++; 
            j--; 
        } 
        return true; 
    }      
    public static void main(String args[])
    {
        try{
            FastReader sc = new FastReader();
            int T = 1;//sc.nextInt();
            while(T-- > 0)
            {
                String str = sc.next();
                out.write(solve(str)+"\n"); 
            }
            try{
                out.flush();
            }catch(Exception e){
                System.out.print("");
            };
        }
        catch(Exception e){
            System.out.print("");
        }
    } 
    public static String solve(String str)
    {       
        long sum = 0;  
        for(int i = 0 ; i < str.length() ; i++)
        {
            sum += (str.charAt(i) - '0');
        }   
        if(sum%9 == 0)
            return "Yes";   
        return "No";
    }      
} Main public final static int d = 256; d 256 static int MOD = 1000000007; MOD 1000000007 static final float EPSILON = (float)0.01; EPSILON (float)0.01 static final double PI = 3.1415926536; PI 3.1415926536 private static BufferedReader in = new BufferedReader (new InputStreamReader (System.in)); in new BufferedReader (new InputStreamReader (System.in)) private static BufferedWriter out = new BufferedWriter (new OutputStreamWriter (System.out)); out new BufferedWriter (new OutputStreamWriter (System.out)) static int searchRabinKarp(String pat, String txt) 
    { 
        int M = pat.length(); 
        int N = txt.length(); 
        int i, j; 
        int p = 0; // hash value for pattern 
        int t = 0; // hash value for txt 
        int h = 1 , cnt = 0; 
        int q = 3355439;         
        for (i = 0; i < M-1; i++) 
            h = (h*d)%q; 
        for (i = 0; i < M; i++) 
        { 
            p = (d*p + pat.charAt(i))%q; 
            t = (d*t + txt.charAt(i))%q; 
        } 
        for (i = 0; i <= N - M; i++) 
        {     
            if ( p == t ) 
            {                 
                for (j = 0; j < M; j++) 
                { 
                    if (txt.charAt(i+j) != pat.charAt(j)) 
                        break; 
                }                 
                if (j == M) 
                {//System.out.println("Pattern found at index " + i);
                    cnt++;
                } 
            } 
            if ( i < N-M ) 
            { 
                t = (d*(t - txt.charAt(i)*h) + txt.charAt(i+M))%q; 
                if (t < 0) 
                    t = (t + q); 
            } 
        } 
        return cnt;
    } searchRabinKarp { 
        int M = pat.length(); 
        int N = txt.length(); 
        int i, j; 
        int p = 0; // hash value for pattern 
        int t = 0; // hash value for txt 
        int h = 1 , cnt = 0; 
        int q = 3355439;         
        for (i = 0; i < M-1; i++) 
            h = (h*d)%q; 
        for (i = 0; i < M; i++) 
        { 
            p = (d*p + pat.charAt(i))%q; 
            t = (d*t + txt.charAt(i))%q; 
        } 
        for (i = 0; i <= N - M; i++) 
        {     
            if ( p == t ) 
            {                 
                for (j = 0; j < M; j++) 
                { 
                    if (txt.charAt(i+j) != pat.charAt(j)) 
                        break; 
                }                 
                if (j == M) 
                {//System.out.println("Pattern found at index " + i);
                    cnt++;
                } 
            } 
            if ( i < N-M ) 
            { 
                t = (d*(t - txt.charAt(i)*h) + txt.charAt(i+M))%q; 
                if (t < 0) 
                    t = (t + q); 
            } 
        } 
        return cnt;
    } int M = pat.length(); M pat.length() pat.length pat int N = txt.length(); N txt.length() txt.length txt int i i j; j int p = 0; p 0 int t = 0; t 0 int h = 1 h 1 cnt = 0; cnt 0 int q = 3355439; q 3355439 for (i = 0; i < M-1; i++) 
            h = (h*d)%q; i = 0; i = 0 i 0 i < M-1 i M-1 M 1 i++ i++ i h = (h*d)%q; h = (h*d)%q h (h*d)%q (h*d) h d q for (i = 0; i < M; i++) 
        { 
            p = (d*p + pat.charAt(i))%q; 
            t = (d*t + txt.charAt(i))%q; 
        } i = 0; i = 0 i 0 i < M i M i++ i++ i { 
            p = (d*p + pat.charAt(i))%q; 
            t = (d*t + txt.charAt(i))%q; 
        } { 
            p = (d*p + pat.charAt(i))%q; 
            t = (d*t + txt.charAt(i))%q; 
        } p = (d*p + pat.charAt(i))%q p (d*p + pat.charAt(i))%q (d*p + pat.charAt(i)) d*p d p pat.charAt(i) pat.charAt pat i q t = (d*t + txt.charAt(i))%q t (d*t + txt.charAt(i))%q (d*t + txt.charAt(i)) d*t d t txt.charAt(i) txt.charAt txt i q for (i = 0; i <= N - M; i++) 
        {     
            if ( p == t ) 
            {                 
                for (j = 0; j < M; j++) 
                { 
                    if (txt.charAt(i+j) != pat.charAt(j)) 
                        break; 
                }                 
                if (j == M) 
                {//System.out.println("Pattern found at index " + i);
                    cnt++;
                } 
            } 
            if ( i < N-M ) 
            { 
                t = (d*(t - txt.charAt(i)*h) + txt.charAt(i+M))%q; 
                if (t < 0) 
                    t = (t + q); 
            } 
        } i = 0; i = 0 i 0 i <= N - M i N - M N M i++ i++ i {     
            if ( p == t ) 
            {                 
                for (j = 0; j < M; j++) 
                { 
                    if (txt.charAt(i+j) != pat.charAt(j)) 
                        break; 
                }                 
                if (j == M) 
                {//System.out.println("Pattern found at index " + i);
                    cnt++;
                } 
            } 
            if ( i < N-M ) 
            { 
                t = (d*(t - txt.charAt(i)*h) + txt.charAt(i+M))%q; 
                if (t < 0) 
                    t = (t + q); 
            } 
        } {     
            if ( p == t ) 
            {                 
                for (j = 0; j < M; j++) 
                { 
                    if (txt.charAt(i+j) != pat.charAt(j)) 
                        break; 
                }                 
                if (j == M) 
                {//System.out.println("Pattern found at index " + i);
                    cnt++;
                } 
            } 
            if ( i < N-M ) 
            { 
                t = (d*(t - txt.charAt(i)*h) + txt.charAt(i+M))%q; 
                if (t < 0) 
                    t = (t + q); 
            } 
        } if ( p == t ) 
            {                 
                for (j = 0; j < M; j++) 
                { 
                    if (txt.charAt(i+j) != pat.charAt(j)) 
                        break; 
                }                 
                if (j == M) 
                {//System.out.println("Pattern found at index " + i);
                    cnt++;
                } 
            } p == t p t {                 
                for (j = 0; j < M; j++) 
                { 
                    if (txt.charAt(i+j) != pat.charAt(j)) 
                        break; 
                }                 
                if (j == M) 
                {//System.out.println("Pattern found at index " + i);
                    cnt++;
                } 
            } for (j = 0; j < M; j++) 
                { 
                    if (txt.charAt(i+j) != pat.charAt(j)) 
                        break; 
                } j = 0; j = 0 j 0 j < M j M j++ j++ j { 
                    if (txt.charAt(i+j) != pat.charAt(j)) 
                        break; 
                } { 
                    if (txt.charAt(i+j) != pat.charAt(j)) 
                        break; 
                } if (txt.charAt(i+j) != pat.charAt(j)) 
                        break; txt.charAt(i+j) != pat.charAt(j) txt.charAt(i+j) txt.charAt txt i+j i j pat.charAt(j) pat.charAt pat j break; if (j == M) 
                {//System.out.println("Pattern found at index " + i);
                    cnt++;
                } j == M j M {//System.out.println("Pattern found at index " + i);
                    cnt++;
                } cnt++ cnt if ( i < N-M ) 
            { 
                t = (d*(t - txt.charAt(i)*h) + txt.charAt(i+M))%q; 
                if (t < 0) 
                    t = (t + q); 
            } i < N-M i N-M N M { 
                t = (d*(t - txt.charAt(i)*h) + txt.charAt(i+M))%q; 
                if (t < 0) 
                    t = (t + q); 
            } t = (d*(t - txt.charAt(i)*h) + txt.charAt(i+M))%q t (d*(t - txt.charAt(i)*h) + txt.charAt(i+M))%q (d*(t - txt.charAt(i)*h) + txt.charAt(i+M)) d*(t - txt.charAt(i)*h) d (t - txt.charAt(i)*h) t txt.charAt(i)*h txt.charAt(i) txt.charAt txt i h txt.charAt(i+M) txt.charAt txt i+M i M q if (t < 0) 
                    t = (t + q); t < 0 t 0 t = (t + q) t (t + q) t q return cnt; cnt String pat pat String txt txt static long gcd(long bigger , long smaller)
    {
            if (smaller == 0) 
                return bigger; 
            return gcd(smaller, bigger % smaller); 
    } gcd {
            if (smaller == 0) 
                return bigger; 
            return gcd(smaller, bigger % smaller); 
    } if (smaller == 0) 
                return bigger; smaller == 0 smaller 0 return bigger; bigger return gcd(smaller, bigger % smaller); gcd(smaller, bigger % smaller) gcd smaller bigger % smaller bigger smaller long bigger bigger long smaller smaller static long lcm(long a, long b) 
    { 
        return (a*b)/gcd(a, b); 
    } lcm { 
        return (a*b)/gcd(a, b); 
    } return (a*b)/gcd(a, b); (a*b)/gcd(a, b) (a*b) a b gcd(a, b) gcd a b long a a long b b static long sumOfArray(long arr[])
    {
        long sum = 0;
        for(int i = 0 ; i < arr.length ; i++)
            sum += arr[i];
        return sum;
    } sumOfArray {
        long sum = 0;
        for(int i = 0 ; i < arr.length ; i++)
            sum += arr[i];
        return sum;
    } long sum = 0; sum 0 for(int i = 0 ; i < arr.length ; i++)
            sum += arr[i]; int i = 0 ; int i = 0 ; i 0 i < arr.length i arr.length arr arr.length i++ i++ i sum += arr[i]; sum += arr[i] sum arr[i] arr i return sum; sum long arr[] arr static boolean isPrime(long n) {
        if(n == 2)
            return true;
        else if(n == 1)
            return false;
        else if (n%2==0)
            return false;          
        for(long i=3;i<=Math.sqrt(n);i+=2) { 
            if(n%i==0) 
                return false; 
        } 
        return true; 
    } isPrime {
        if(n == 2)
            return true;
        else if(n == 1)
            return false;
        else if (n%2==0)
            return false;          
        for(long i=3;i<=Math.sqrt(n);i+=2) { 
            if(n%i==0) 
                return false; 
        } 
        return true; 
    } if(n == 2)
            return true;
        else if(n == 1)
            return false;
        else if (n%2==0)
            return false; n == 2 n 2 return true; true if(n == 1)
            return false;
        else if (n%2==0)
            return false; n == 1 n 1 return false; false if (n%2==0)
            return false; n%2==0 n%2 n 2 0 return false; false for(long i=3;i<=Math.sqrt(n);i+=2) { 
            if(n%i==0) 
                return false; 
        } long i=3; long i=3; i 3 i<=Math.sqrt(n) i Math.sqrt(n) Math.sqrt Math n i+=2 i+=2 i 2 { 
            if(n%i==0) 
                return false; 
        } { 
            if(n%i==0) 
                return false; 
        } if(n%i==0) 
                return false; n%i==0 n%i n i 0 return false; false return true; true long n n static long countDigit(long n) 
    { 
        return (long)Math.floor(Math.log10(n) + 1); 
    } countDigit { 
        return (long)Math.floor(Math.log10(n) + 1); 
    } return (long)Math.floor(Math.log10(n) + 1); (long)Math.floor(Math.log10(n) + 1) Math.floor Math Math.log10(n) + 1 Math.log10(n) Math.log10 Math n 1 long n n static long sumOfDigits(long n) 
    { 
        long sum;        
        for (sum = 0; n > 0; sum += n % 10,n /= 10);   
        return sum; 
    } sumOfDigits { 
        long sum;        
        for (sum = 0; n > 0; sum += n % 10,n /= 10);   
        return sum; 
    } long sum; sum for (sum = 0; n > 0; sum += n % 10,n /= 10); sum = 0; sum = 0 sum 0 n > 0 n 0 sum += n % 10,n /= 10 sum += n % 10 sum n % 10 n 10 n /= 10 n 10 ; return sum; sum long n n static boolean isPalindrome(String str) 
    {   
        int i = 0, j = str.length() - 1; 
        while (i < j) { 
            if (str.charAt(i) != str.charAt(j)) 
                return false; 
            i++; 
            j--; 
        } 
        return true; 
    } isPalindrome {   
        int i = 0, j = str.length() - 1; 
        while (i < j) { 
            if (str.charAt(i) != str.charAt(j)) 
                return false; 
            i++; 
            j--; 
        } 
        return true; 
    } int i = 0 i 0 j = str.length() - 1; j str.length() - 1 str.length() str.length str 1 while (i < j) { 
            if (str.charAt(i) != str.charAt(j)) 
                return false; 
            i++; 
            j--; 
        } i < j i j { 
            if (str.charAt(i) != str.charAt(j)) 
                return false; 
            i++; 
            j--; 
        } if (str.charAt(i) != str.charAt(j)) 
                return false; str.charAt(i) != str.charAt(j) str.charAt(i) str.charAt str i str.charAt(j) str.charAt str j return false; false i++ i j-- j return true; true String str str public static void main(String args[])
    {
        try{
            FastReader sc = new FastReader();
            int T = 1;//sc.nextInt();
            while(T-- > 0)
            {
                String str = sc.next();
                out.write(solve(str)+"\n"); 
            }
            try{
                out.flush();
            }catch(Exception e){
                System.out.print("");
            };
        }
        catch(Exception e){
            System.out.print("");
        }
    } main {
        try{
            FastReader sc = new FastReader();
            int T = 1;//sc.nextInt();
            while(T-- > 0)
            {
                String str = sc.next();
                out.write(solve(str)+"\n"); 
            }
            try{
                out.flush();
            }catch(Exception e){
                System.out.print("");
            };
        }
        catch(Exception e){
            System.out.print("");
        }
    } try{
            FastReader sc = new FastReader();
            int T = 1;//sc.nextInt();
            while(T-- > 0)
            {
                String str = sc.next();
                out.write(solve(str)+"\n"); 
            }
            try{
                out.flush();
            }catch(Exception e){
                System.out.print("");
            };
        }
        catch(Exception e){
            System.out.print("");
        } catch(Exception e){
            System.out.print("");
        } Exception e {
            System.out.print("");
        } System.out.print("") System.out.print System.out System System.out "" {
            FastReader sc = new FastReader();
            int T = 1;//sc.nextInt();
            while(T-- > 0)
            {
                String str = sc.next();
                out.write(solve(str)+"\n"); 
            }
            try{
                out.flush();
            }catch(Exception e){
                System.out.print("");
            };
        } FastReader sc = new FastReader(); sc new FastReader() int T = 1; T 1 while(T-- > 0)
            {
                String str = sc.next();
                out.write(solve(str)+"\n"); 
            } T-- > 0 T-- T 0 {
                String str = sc.next();
                out.write(solve(str)+"\n"); 
            } String str = sc.next(); str sc.next() sc.next sc out.write(solve(str)+"\n") out.write out solve(str)+"\n" solve(str) solve str "\n" try{
                out.flush();
            }catch(Exception e){
                System.out.print("");
            } catch(Exception e){
                System.out.print("");
            } Exception e {
                System.out.print("");
            } System.out.print("") System.out.print System.out System System.out "" {
                out.flush();
            } out.flush() out.flush out String args[] args public static String solve(String str)
    {       
        long sum = 0;  
        for(int i = 0 ; i < str.length() ; i++)
        {
            sum += (str.charAt(i) - '0');
        }   
        if(sum%9 == 0)
            return "Yes";   
        return "No";
    } solve {       
        long sum = 0;  
        for(int i = 0 ; i < str.length() ; i++)
        {
            sum += (str.charAt(i) - '0');
        }   
        if(sum%9 == 0)
            return "Yes";   
        return "No";
    } long sum = 0; sum 0 for(int i = 0 ; i < str.length() ; i++)
        {
            sum += (str.charAt(i) - '0');
        } int i = 0 ; int i = 0 ; i 0 i < str.length() i str.length() str.length str i++ i++ i {
            sum += (str.charAt(i) - '0');
        } {
            sum += (str.charAt(i) - '0');
        } sum += (str.charAt(i) - '0') sum (str.charAt(i) - '0') str.charAt(i) str.charAt str i '0' if(sum%9 == 0)
            return "Yes"; sum%9 == 0 sum%9 sum 9 0 return "Yes"; "Yes" return "No"; "No" String str str 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()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        {
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 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 long nextLong() 
        { 
            return Long.parseLong(next()); 
        } nextLong { 
            return Long.parseLong(next()); 
        } return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } nextDouble { 
            return Double.parseDouble(next()); 
        } return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next String nextLine() 
        {
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } nextLine {
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } String str = ""; str "" try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } catch (IOException e) 
            { 
                e.printStackTrace(); 
            } IOException e { 
                e.printStackTrace(); 
            } e.printStackTrace() e.printStackTrace e { 
                str = br.readLine(); 
            } str = br.readLine() str br.readLine() br.readLine br return str; str public class Main
{
    public final static int d = 256; 
    static int MOD = 1000000007;
    static final float EPSILON = (float)0.01; 
    static final double PI = 3.1415926536;
    private static BufferedReader in = new BufferedReader (new InputStreamReader (System.in));
    private static BufferedWriter out = new BufferedWriter (new OutputStreamWriter (System.out));
    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()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        {
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
    static int searchRabinKarp(String pat, String txt) 
    { 
        int M = pat.length(); 
        int N = txt.length(); 
        int i, j; 
        int p = 0; // hash value for pattern 
        int t = 0; // hash value for txt 
        int h = 1 , cnt = 0; 
        int q = 3355439;         
        for (i = 0; i < M-1; i++) 
            h = (h*d)%q; 
        for (i = 0; i < M; i++) 
        { 
            p = (d*p + pat.charAt(i))%q; 
            t = (d*t + txt.charAt(i))%q; 
        } 
        for (i = 0; i <= N - M; i++) 
        {     
            if ( p == t ) 
            {                 
                for (j = 0; j < M; j++) 
                { 
                    if (txt.charAt(i+j) != pat.charAt(j)) 
                        break; 
                }                 
                if (j == M) 
                {//System.out.println("Pattern found at index " + i);
                    cnt++;
                } 
            } 
            if ( i < N-M ) 
            { 
                t = (d*(t - txt.charAt(i)*h) + txt.charAt(i+M))%q; 
                if (t < 0) 
                    t = (t + q); 
            } 
        } 
        return cnt;
    }
    static long gcd(long bigger , long smaller)
    {
            if (smaller == 0) 
                return bigger; 
            return gcd(smaller, bigger % smaller); 
    }
    static long lcm(long a, long b) 
    { 
        return (a*b)/gcd(a, b); 
    } 
    static long sumOfArray(long arr[])
    {
        long sum = 0;
        for(int i = 0 ; i < arr.length ; i++)
            sum += arr[i];
        return sum;
    }
    static boolean isPrime(long n) {
        if(n == 2)
            return true;
        else if(n == 1)
            return false;
        else if (n%2==0)
            return false;          
        for(long i=3;i<=Math.sqrt(n);i+=2) { 
            if(n%i==0) 
                return false; 
        } 
        return true; 
    }
    static long countDigit(long n) 
    { 
        return (long)Math.floor(Math.log10(n) + 1); 
    }
    static long sumOfDigits(long n) 
    { 
        long sum;        
        for (sum = 0; n > 0; sum += n % 10,n /= 10);   
        return sum; 
    }        
    static boolean isPalindrome(String str) 
    {   
        int i = 0, j = str.length() - 1; 
        while (i < j) { 
            if (str.charAt(i) != str.charAt(j)) 
                return false; 
            i++; 
            j--; 
        } 
        return true; 
    }      
    public static void main(String args[])
    {
        try{
            FastReader sc = new FastReader();
            int T = 1;//sc.nextInt();
            while(T-- > 0)
            {
                String str = sc.next();
                out.write(solve(str)+"\n"); 
            }
            try{
                out.flush();
            }catch(Exception e){
                System.out.print("");
            };
        }
        catch(Exception e){
            System.out.print("");
        }
    } 
    public static String solve(String str)
    {       
        long sum = 0;  
        for(int i = 0 ; i < str.length() ; i++)
        {
            sum += (str.charAt(i) - '0');
        }   
        if(sum%9 == 0)
            return "Yes";   
        return "No";
    }      
} public class Main
{
    public final static int d = 256; 
    static int MOD = 1000000007;
    static final float EPSILON = (float)0.01; 
    static final double PI = 3.1415926536;
    private static BufferedReader in = new BufferedReader (new InputStreamReader (System.in));
    private static BufferedWriter out = new BufferedWriter (new OutputStreamWriter (System.out));
    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()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        {
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
    static int searchRabinKarp(String pat, String txt) 
    { 
        int M = pat.length(); 
        int N = txt.length(); 
        int i, j; 
        int p = 0; // hash value for pattern 
        int t = 0; // hash value for txt 
        int h = 1 , cnt = 0; 
        int q = 3355439;         
        for (i = 0; i < M-1; i++) 
            h = (h*d)%q; 
        for (i = 0; i < M; i++) 
        { 
            p = (d*p + pat.charAt(i))%q; 
            t = (d*t + txt.charAt(i))%q; 
        } 
        for (i = 0; i <= N - M; i++) 
        {     
            if ( p == t ) 
            {                 
                for (j = 0; j < M; j++) 
                { 
                    if (txt.charAt(i+j) != pat.charAt(j)) 
                        break; 
                }                 
                if (j == M) 
                {//System.out.println("Pattern found at index " + i);
                    cnt++;
                } 
            } 
            if ( i < N-M ) 
            { 
                t = (d*(t - txt.charAt(i)*h) + txt.charAt(i+M))%q; 
                if (t < 0) 
                    t = (t + q); 
            } 
        } 
        return cnt;
    }
    static long gcd(long bigger , long smaller)
    {
            if (smaller == 0) 
                return bigger; 
            return gcd(smaller, bigger % smaller); 
    }
    static long lcm(long a, long b) 
    { 
        return (a*b)/gcd(a, b); 
    } 
    static long sumOfArray(long arr[])
    {
        long sum = 0;
        for(int i = 0 ; i < arr.length ; i++)
            sum += arr[i];
        return sum;
    }
    static boolean isPrime(long n) {
        if(n == 2)
            return true;
        else if(n == 1)
            return false;
        else if (n%2==0)
            return false;          
        for(long i=3;i<=Math.sqrt(n);i+=2) { 
            if(n%i==0) 
                return false; 
        } 
        return true; 
    }
    static long countDigit(long n) 
    { 
        return (long)Math.floor(Math.log10(n) + 1); 
    }
    static long sumOfDigits(long n) 
    { 
        long sum;        
        for (sum = 0; n > 0; sum += n % 10,n /= 10);   
        return sum; 
    }        
    static boolean isPalindrome(String str) 
    {   
        int i = 0, j = str.length() - 1; 
        while (i < j) { 
            if (str.charAt(i) != str.charAt(j)) 
                return false; 
            i++; 
            j--; 
        } 
        return true; 
    }      
    public static void main(String args[])
    {
        try{
            FastReader sc = new FastReader();
            int T = 1;//sc.nextInt();
            while(T-- > 0)
            {
                String str = sc.next();
                out.write(solve(str)+"\n"); 
            }
            try{
                out.flush();
            }catch(Exception e){
                System.out.print("");
            };
        }
        catch(Exception e){
            System.out.print("");
        }
    } 
    public static String solve(String str)
    {       
        long sum = 0;  
        for(int i = 0 ; i < str.length() ; i++)
        {
            sum += (str.charAt(i) - '0');
        }   
        if(sum%9 == 0)
            return "Yes";   
        return "No";
    }      
} Main
//JAI BAJRANGBALI                                                                                                                                               
import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class Main
{
    public final static int d = 256; 
    static int MOD = 1000000007;
    static final float EPSILON = (float)0.01; 
    static final double PI = 3.1415926536;
    private static BufferedReader in = new BufferedReader (new InputStreamReader (System.in));
    private static BufferedWriter out = new BufferedWriter (new OutputStreamWriter (System.out));
    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()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        {
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
    static int searchRabinKarp(String pat, String txt) 
    { 
        int M = pat.length(); 
        int N = txt.length(); 
        int i, j; 
        int p = 0; // hash value for pattern 
        int t = 0; // hash value for txt 
        int h = 1 , cnt = 0; 
        int q = 3355439;         
        for (i = 0; i < M-1; i++) 
            h = (h*d)%q; 
        for (i = 0; i < M; i++) 
        { 
            p = (d*p + pat.charAt(i))%q; 
            t = (d*t + txt.charAt(i))%q; 
        } 
        for (i = 0; i <= N - M; i++) 
        {     
            if ( p == t ) 
            {                 
                for (j = 0; j < M; j++) 
                { 
                    if (txt.charAt(i+j) != pat.charAt(j)) 
                        break; 
                }                 
                if (j == M) 
                {//System.out.println("Pattern found at index " + i);
                    cnt++;
                } 
            } 
            if ( i < N-M ) 
            { 
                t = (d*(t - txt.charAt(i)*h) + txt.charAt(i+M))%q; 
                if (t < 0) 
                    t = (t + q); 
            } 
        } 
        return cnt;
    }
    static long gcd(long bigger , long smaller)
    {
            if (smaller == 0) 
                return bigger; 
            return gcd(smaller, bigger % smaller); 
    }
    static long lcm(long a, long b) 
    { 
        return (a*b)/gcd(a, b); 
    } 
    static long sumOfArray(long arr[])
    {
        long sum = 0;
        for(int i = 0 ; i < arr.length ; i++)
            sum += arr[i];
        return sum;
    }
    static boolean isPrime(long n) {
        if(n == 2)
            return true;
        else if(n == 1)
            return false;
        else if (n%2==0)
            return false;          
        for(long i=3;i<=Math.sqrt(n);i+=2) { 
            if(n%i==0) 
                return false; 
        } 
        return true; 
    }
    static long countDigit(long n) 
    { 
        return (long)Math.floor(Math.log10(n) + 1); 
    }
    static long sumOfDigits(long n) 
    { 
        long sum;        
        for (sum = 0; n > 0; sum += n % 10,n /= 10);   
        return sum; 
    }        
    static boolean isPalindrome(String str) 
    {   
        int i = 0, j = str.length() - 1; 
        while (i < j) { 
            if (str.charAt(i) != str.charAt(j)) 
                return false; 
            i++; 
            j--; 
        } 
        return true; 
    }      
    public static void main(String args[])
    {
        try{
            FastReader sc = new FastReader();
            int T = 1;//sc.nextInt();
            while(T-- > 0)
            {
                String str = sc.next();
                out.write(solve(str)+"\n"); 
            }
            try{
                out.flush();
            }catch(Exception e){
                System.out.print("");
            };
        }
        catch(Exception e){
            System.out.print("");
        }
    } 
    public static String solve(String str)
    {       
        long sum = 0;  
        for(int i = 0 ; i < str.length() ; i++)
        {
            sum += (str.charAt(i) - '0');
        }   
        if(sum%9 == 0)
            return "Yes";   
        return "No";
    }      
}   