import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n = sc.nextLine();
        long sum = 0;
        int len = n.length();
        for(int i = 0;i<len;i++){
            sum += (int)n.charAt(i) - '0';
        }
        //System.out.println(sum);
        if(sum % 9 == 0)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
} import java.util.*; util.* java class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n = sc.nextLine();
        long sum = 0;
        int len = n.length();
        for(int i = 0;i<len;i++){
            sum += (int)n.charAt(i) - '0';
        }
        //System.out.println(sum);
        if(sum % 9 == 0)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n = sc.nextLine();
        long sum = 0;
        int len = n.length();
        for(int i = 0;i<len;i++){
            sum += (int)n.charAt(i) - '0';
        }
        //System.out.println(sum);
        if(sum % 9 == 0)
            System.out.println("Yes");
        else
            System.out.println("No");
    } main {
        Scanner sc = new Scanner(System.in);
        String n = sc.nextLine();
        long sum = 0;
        int len = n.length();
        for(int i = 0;i<len;i++){
            sum += (int)n.charAt(i) - '0';
        }
        //System.out.println(sum);
        if(sum % 9 == 0)
            System.out.println("Yes");
        else
            System.out.println("No");
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String n = sc.nextLine(); n sc.nextLine() sc.nextLine sc long sum = 0; sum 0 int len = n.length(); len n.length() n.length n for(int i = 0;i<len;i++){
            sum += (int)n.charAt(i) - '0';
        } int i = 0; int i = 0; i 0 i<len i len i++ i++ i {
            sum += (int)n.charAt(i) - '0';
        } {
            sum += (int)n.charAt(i) - '0';
        } sum += (int)n.charAt(i) - '0' sum (int)n.charAt(i) - '0' (int)n.charAt(i) n.charAt n i '0' if(sum % 9 == 0)
            System.out.println("Yes");
        else
            System.out.println("No"); sum % 9 == 0 sum % 9 sum 9 0 System.out.println("Yes") System.out.println System.out System System.out "Yes" System.out.println("No") System.out.println System.out System System.out "No" String[] args args
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n = sc.nextLine();
        long sum = 0;
        int len = n.length();
        for(int i = 0;i<len;i++){
            sum += (int)n.charAt(i) - '0';
        }
        //System.out.println(sum);
        if(sum % 9 == 0)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}