import java.io.*;
 
/**
 * Created by Ayushi on 22 Aug 2020.
 * Problem:
 * Round:
 */
 
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String a  = br.readLine();
        long ans = 0;
        for (int i = 0; i < a.length(); i++) {
          ans += Integer.parseInt(a.substring(i,i+1));
        }

        System.out.println((ans%9==0) ? "Yes":"No");
        //System.out.println(ans);
    }
} import java.io.*; io.* java public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String a  = br.readLine();
        long ans = 0;
        for (int i = 0; i < a.length(); i++) {
          ans += Integer.parseInt(a.substring(i,i+1));
        }

        System.out.println((ans%9==0) ? "Yes":"No");
        //System.out.println(ans);
    }
} Main public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String a  = br.readLine();
        long ans = 0;
        for (int i = 0; i < a.length(); i++) {
          ans += Integer.parseInt(a.substring(i,i+1));
        }

        System.out.println((ans%9==0) ? "Yes":"No");
        //System.out.println(ans);
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String a  = br.readLine();
        long ans = 0;
        for (int i = 0; i < a.length(); i++) {
          ans += Integer.parseInt(a.substring(i,i+1));
        }

        System.out.println((ans%9==0) ? "Yes":"No");
        //System.out.println(ans);
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String a  = br.readLine(); a br.readLine() br.readLine br long ans = 0; ans 0 for (int i = 0; i < a.length(); i++) {
          ans += Integer.parseInt(a.substring(i,i+1));
        } int i = 0; int i = 0; i 0 i < a.length() i a.length() a.length a i++ i++ i {
          ans += Integer.parseInt(a.substring(i,i+1));
        } {
          ans += Integer.parseInt(a.substring(i,i+1));
        } ans += Integer.parseInt(a.substring(i,i+1)) ans Integer.parseInt(a.substring(i,i+1)) Integer.parseInt Integer a.substring(i,i+1) a.substring a i i+1 i 1 System.out.println((ans%9==0) ? "Yes":"No") System.out.println System.out System System.out (ans%9==0) ? "Yes":"No" (ans%9==0) ans%9 ans 9 0 "Yes" "No" String[] args args public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String a  = br.readLine();
        long ans = 0;
        for (int i = 0; i < a.length(); i++) {
          ans += Integer.parseInt(a.substring(i,i+1));
        }

        System.out.println((ans%9==0) ? "Yes":"No");
        //System.out.println(ans);
    }
} public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String a  = br.readLine();
        long ans = 0;
        for (int i = 0; i < a.length(); i++) {
          ans += Integer.parseInt(a.substring(i,i+1));
        }

        System.out.println((ans%9==0) ? "Yes":"No");
        //System.out.println(ans);
    }
} Main
import java.io.*;
 
/**
 * Created by Ayushi on 22 Aug 2020.
 * Problem:
 * Round:
 */
 
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String a  = br.readLine();
        long ans = 0;
        for (int i = 0; i < a.length(); i++) {
          ans += Integer.parseInt(a.substring(i,i+1));
        }

        System.out.println((ans%9==0) ? "Yes":"No");
        //System.out.println(ans);
    }
}