import java.util.Scanner;
class Main {
    public static void main(final String[] args) {
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        String[] ar = N.split("");
        int sum=0;
        
        for(int i=0;i<N.length();i++){
            sum += Integer.parseInt(ar[i]);
        }
        String ans="No";
        if(sum%9==0) ans = "Yes";
        System.out.println(ans);
    }
} import java.util.Scanner; Scanner java.util class Main {
    public static void main(final String[] args) {
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        String[] ar = N.split("");
        int sum=0;
        
        for(int i=0;i<N.length();i++){
            sum += Integer.parseInt(ar[i]);
        }
        String ans="No";
        if(sum%9==0) ans = "Yes";
        System.out.println(ans);
    }
} Main public static void main(final String[] args) {
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        String[] ar = N.split("");
        int sum=0;
        
        for(int i=0;i<N.length();i++){
            sum += Integer.parseInt(ar[i]);
        }
        String ans="No";
        if(sum%9==0) ans = "Yes";
        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        String[] ar = N.split("");
        int sum=0;
        
        for(int i=0;i<N.length();i++){
            sum += Integer.parseInt(ar[i]);
        }
        String ans="No";
        if(sum%9==0) ans = "Yes";
        System.out.println(ans);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String N = sc.next(); N sc.next() sc.next sc String[] ar = N.split(""); ar N.split("") N.split N "" int sum=0; sum 0 for(int i=0;i<N.length();i++){
            sum += Integer.parseInt(ar[i]);
        } int i=0; int i=0; i 0 i<N.length() i N.length() N.length N i++ i++ i {
            sum += Integer.parseInt(ar[i]);
        } {
            sum += Integer.parseInt(ar[i]);
        } sum += Integer.parseInt(ar[i]) sum Integer.parseInt(ar[i]) Integer.parseInt Integer ar[i] ar i String ans="No"; ans "No" if(sum%9==0) ans = "Yes"; sum%9==0 sum%9 sum 9 0 ans = "Yes" ans "Yes" System.out.println(ans) System.out.println System.out System System.out ans final String[] args args
import java.util.Scanner;
class Main {
    public static void main(final String[] args) {
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        String[] ar = N.split("");
        int sum=0;
        
        for(int i=0;i<N.length();i++){
            sum += Integer.parseInt(ar[i]);
        }
        String ans="No";
        if(sum%9==0) ans = "Yes";
        System.out.println(ans);
    }
}