import java.util.*;

public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                String str = sc.nextLine();
                sc.close();
        //int N = Integer.parseInt(str);

                int count=0;

        for(int i = 0; i < str.length(); i++){
            count += str.charAt(i) - '0';
        }


                System.out.println((count%9 == 0) ? "Yes" : "No");
        }
}
 import java.util.*; util.* java public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                String str = sc.nextLine();
                sc.close();
        //int N = Integer.parseInt(str);

                int count=0;

        for(int i = 0; i < str.length(); i++){
            count += str.charAt(i) - '0';
        }


                System.out.println((count%9 == 0) ? "Yes" : "No");
        }
} Main public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                String str = sc.nextLine();
                sc.close();
        //int N = Integer.parseInt(str);

                int count=0;

        for(int i = 0; i < str.length(); i++){
            count += str.charAt(i) - '0';
        }


                System.out.println((count%9 == 0) ? "Yes" : "No");
        } main {
                Scanner sc = new Scanner(System.in);
                String str = sc.nextLine();
                sc.close();
        //int N = Integer.parseInt(str);

                int count=0;

        for(int i = 0; i < str.length(); i++){
            count += str.charAt(i) - '0';
        }


                System.out.println((count%9 == 0) ? "Yes" : "No");
        } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String str = sc.nextLine(); str sc.nextLine() sc.nextLine sc sc.close() sc.close sc int count=0; count 0 for(int i = 0; i < str.length(); i++){
            count += str.charAt(i) - '0';
        } int i = 0; int i = 0; i 0 i < str.length() i str.length() str.length str i++ i++ i {
            count += str.charAt(i) - '0';
        } {
            count += str.charAt(i) - '0';
        } count += str.charAt(i) - '0' count str.charAt(i) - '0' str.charAt(i) str.charAt str i '0' System.out.println((count%9 == 0) ? "Yes" : "No") System.out.println System.out System System.out (count%9 == 0) ? "Yes" : "No" (count%9 == 0) count%9 count 9 0 "Yes" "No" String[] args args public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                String str = sc.nextLine();
                sc.close();
        //int N = Integer.parseInt(str);

                int count=0;

        for(int i = 0; i < str.length(); i++){
            count += str.charAt(i) - '0';
        }


                System.out.println((count%9 == 0) ? "Yes" : "No");
        }
} public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                String str = sc.nextLine();
                sc.close();
        //int N = Integer.parseInt(str);

                int count=0;

        for(int i = 0; i < str.length(); i++){
            count += str.charAt(i) - '0';
        }


                System.out.println((count%9 == 0) ? "Yes" : "No");
        }
} Main
import java.util.*;

public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                String str = sc.nextLine();
                sc.close();
        //int N = Integer.parseInt(str);

                int count=0;

        for(int i = 0; i < str.length(); i++){
            count += str.charAt(i) - '0';
        }


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

