import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        String n = sc.next();
        char[] c = n.toCharArray();
        
        int sum = 0;
        for(char c2: c){
            sum += (c2 - '0');
        }
        
        if(sum % 9 == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
} import java.util.Scanner; Scanner java.util class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        String n = sc.next();
        char[] c = n.toCharArray();
        
        int sum = 0;
        for(char c2: c){
            sum += (c2 - '0');
        }
        
        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.next();
        char[] c = n.toCharArray();
        
        int sum = 0;
        for(char c2: c){
            sum += (c2 - '0');
        }
        
        if(sum % 9 == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    } main {
        Scanner sc = new Scanner(System.in);
        
        String n = sc.next();
        char[] c = n.toCharArray();
        
        int sum = 0;
        for(char c2: c){
            sum += (c2 - '0');
        }
        
        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.next(); n sc.next() sc.next sc char[] c = n.toCharArray(); c n.toCharArray() n.toCharArray n int sum = 0; sum 0 for(char c2: c){
            sum += (c2 - '0');
        } char c2 c {
            sum += (c2 - '0');
        } {
            sum += (c2 - '0');
        } sum += (c2 - '0') sum (c2 - '0') c2 '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("Yes") System.out.println System.out System System.out "Yes" {
            System.out.println("No");
        } System.out.println("No") System.out.println System.out System System.out "No" String[] args args
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        String n = sc.next();
        char[] c = n.toCharArray();
        
        int sum = 0;
        for(char c2: c){
            sum += (c2 - '0');
        }
        
        if(sum % 9 == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}