import java.util.*; 
import java.io.*;

//the answer must be bountry * bountry
public class Main  {
    static StringTokenizer st;
    static BufferedReader br;  
    static PrintWriter out;
 
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
 
        String S = next();
 
        int sum = 0;

        for (int i=0; i<S.length(); i++) {
             int temp = S.charAt(i)-'0';
             sum += temp;
        }

        if(sum%9==0){
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
        
 
    }
    
      
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
} import java.util.*; util.* java import java.io.*; io.* java public class Main  {
    static StringTokenizer st;
    static BufferedReader br;  
    static PrintWriter out;
 
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
 
        String S = next();
 
        int sum = 0;

        for (int i=0; i<S.length(); i++) {
             int temp = S.charAt(i)-'0';
             sum += temp;
        }

        if(sum%9==0){
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
        
 
    }
    
      
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
} Main static StringTokenizer st; st static BufferedReader br; br static PrintWriter out; out public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
 
        String S = next();
 
        int sum = 0;

        for (int i=0; i<S.length(); i++) {
             int temp = S.charAt(i)-'0';
             sum += temp;
        }

        if(sum%9==0){
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
        
 
    } main {
        br = new BufferedReader(new InputStreamReader(System.in));
 
        String S = next();
 
        int sum = 0;

        for (int i=0; i<S.length(); i++) {
             int temp = S.charAt(i)-'0';
             sum += temp;
        }

        if(sum%9==0){
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
        
 
    } br = new BufferedReader(new InputStreamReader(System.in)) br new BufferedReader(new InputStreamReader(System.in)) String S = next(); S next() next int sum = 0; sum 0 for (int i=0; i<S.length(); i++) {
             int temp = S.charAt(i)-'0';
             sum += temp;
        } int i=0; int i=0; i 0 i<S.length() i S.length() S.length S i++ i++ i {
             int temp = S.charAt(i)-'0';
             sum += temp;
        } {
             int temp = S.charAt(i)-'0';
             sum += temp;
        } int temp = S.charAt(i)-'0'; temp S.charAt(i)-'0' S.charAt(i) S.charAt S i '0' sum += temp sum temp 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 public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    } nextInt {
        return Integer.parseInt(next());
    } return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next public static long nextLong() throws IOException {
        return Long.parseLong(next());
    } nextLong {
        return Long.parseLong(next());
    } return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    } nextDouble {
        return Double.parseDouble(next());
    } return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    } next {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    } while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim()); st == null || !st.hasMoreTokens() st == null st null !st.hasMoreTokens() st.hasMoreTokens() st.hasMoreTokens st st = new StringTokenizer(br.readLine().trim()) st new StringTokenizer(br.readLine().trim()) return st.nextToken(); st.nextToken() st.nextToken st public class Main  {
    static StringTokenizer st;
    static BufferedReader br;  
    static PrintWriter out;
 
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
 
        String S = next();
 
        int sum = 0;

        for (int i=0; i<S.length(); i++) {
             int temp = S.charAt(i)-'0';
             sum += temp;
        }

        if(sum%9==0){
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
        
 
    }
    
      
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
} public class Main  {
    static StringTokenizer st;
    static BufferedReader br;  
    static PrintWriter out;
 
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
 
        String S = next();
 
        int sum = 0;

        for (int i=0; i<S.length(); i++) {
             int temp = S.charAt(i)-'0';
             sum += temp;
        }

        if(sum%9==0){
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
        
 
    }
    
      
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
} Main
import java.util.*; 
import java.io.*;

//the answer must be bountry * bountry
public class Main  {
    static StringTokenizer st;
    static BufferedReader br;  
    static PrintWriter out;
 
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
 
        String S = next();
 
        int sum = 0;

        for (int i=0; i<S.length(); i++) {
             int temp = S.charAt(i)-'0';
             sum += temp;
        }

        if(sum%9==0){
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
        
 
    }
    
      
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}
