import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String strn = sc.next();
        sc.close();
        String  str[] = strn.split("");

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

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

        int sum = 0;
        for(int i = 0; i<strn.length(); i++){
            sum += Integer.parseInt(str[i]);
        }
        String ans = "No";
        if(sum%9==0){
            ans = "Yes";
        }
        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        String strn = sc.next();
        sc.close();
        String  str[] = strn.split("");

        int sum = 0;
        for(int i = 0; i<strn.length(); i++){
            sum += Integer.parseInt(str[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 strn = sc.next(); strn sc.next() sc.next sc sc.close() sc.close sc String  str[] = strn.split(""); str strn.split("") strn.split strn "" int sum = 0; sum 0 for(int i = 0; i<strn.length(); i++){
            sum += Integer.parseInt(str[i]);
        } int i = 0; int i = 0; i 0 i<strn.length() i strn.length() strn.length strn i++ i++ i {
            sum += Integer.parseInt(str[i]);
        } {
            sum += Integer.parseInt(str[i]);
        } sum += Integer.parseInt(str[i]) sum Integer.parseInt(str[i]) Integer.parseInt Integer str[i] str i String ans = "No"; ans "No" if(sum%9==0){
            ans = "Yes";
        } sum%9==0 sum%9 sum 9 0 {
            ans = "Yes";
        } ans = "Yes" ans "Yes" System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String strn = sc.next();
        sc.close();
        String  str[] = strn.split("");

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

        int sum = 0;
        for(int i = 0; i<strn.length(); i++){
            sum += Integer.parseInt(str[i]);
        }
        String ans = "No";
        if(sum%9==0){
            ans = "Yes";
        }
        System.out.println(ans);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String strn = sc.next();
        sc.close();
        String  str[] = strn.split("");

        int sum = 0;
        for(int i = 0; i<strn.length(); i++){
            sum += Integer.parseInt(str[i]);
        }
        String ans = "No";
        if(sum%9==0){
            ans = "Yes";
        }
        System.out.println(ans);
    }
}
