//package basics.AtCoders;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s= new Scanner(System.in);
        String n=s.nextLine();
        int sum=0;
        for(int i=0;i<n.toString().length();i++){
            sum = sum + Integer.parseInt(String.valueOf(n.charAt(i)));;
        }
        System.out.println((sum%9==0)?"Yes":"No");
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner s= new Scanner(System.in);
        String n=s.nextLine();
        int sum=0;
        for(int i=0;i<n.toString().length();i++){
            sum = sum + Integer.parseInt(String.valueOf(n.charAt(i)));;
        }
        System.out.println((sum%9==0)?"Yes":"No");
    }
} Main public static void main(String[] args) {
        Scanner s= new Scanner(System.in);
        String n=s.nextLine();
        int sum=0;
        for(int i=0;i<n.toString().length();i++){
            sum = sum + Integer.parseInt(String.valueOf(n.charAt(i)));;
        }
        System.out.println((sum%9==0)?"Yes":"No");
    } main {
        Scanner s= new Scanner(System.in);
        String n=s.nextLine();
        int sum=0;
        for(int i=0;i<n.toString().length();i++){
            sum = sum + Integer.parseInt(String.valueOf(n.charAt(i)));;
        }
        System.out.println((sum%9==0)?"Yes":"No");
    } Scanner s= new Scanner(System.in); s new Scanner(System.in) String n=s.nextLine(); n s.nextLine() s.nextLine s int sum=0; sum 0 for(int i=0;i<n.toString().length();i++){
            sum = sum + Integer.parseInt(String.valueOf(n.charAt(i)));;
        } int i=0; int i=0; i 0 i<n.toString().length() i n.toString().length() n.toString().length n.toString() n.toString n i++ i++ i {
            sum = sum + Integer.parseInt(String.valueOf(n.charAt(i)));;
        } {
            sum = sum + Integer.parseInt(String.valueOf(n.charAt(i)));;
        } sum = sum + Integer.parseInt(String.valueOf(n.charAt(i))) sum sum + Integer.parseInt(String.valueOf(n.charAt(i))) sum Integer.parseInt(String.valueOf(n.charAt(i))) Integer.parseInt Integer String.valueOf(n.charAt(i)) String.valueOf String n.charAt(i) n.charAt n i System.out.println((sum%9==0)?"Yes":"No") System.out.println System.out System System.out (sum%9==0)?"Yes":"No" (sum%9==0) sum%9 sum 9 0 "Yes" "No" String[] args args public class Main {
    public static void main(String[] args) {
        Scanner s= new Scanner(System.in);
        String n=s.nextLine();
        int sum=0;
        for(int i=0;i<n.toString().length();i++){
            sum = sum + Integer.parseInt(String.valueOf(n.charAt(i)));;
        }
        System.out.println((sum%9==0)?"Yes":"No");
    }
} public class Main {
    public static void main(String[] args) {
        Scanner s= new Scanner(System.in);
        String n=s.nextLine();
        int sum=0;
        for(int i=0;i<n.toString().length();i++){
            sum = sum + Integer.parseInt(String.valueOf(n.charAt(i)));;
        }
        System.out.println((sum%9==0)?"Yes":"No");
    }
} Main
//package basics.AtCoders;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s= new Scanner(System.in);
        String n=s.nextLine();
        int sum=0;
        for(int i=0;i<n.toString().length();i++){
            sum = sum + Integer.parseInt(String.valueOf(n.charAt(i)));;
        }
        System.out.println((sum%9==0)?"Yes":"No");
    }
}
