import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        char[] s = br.readLine().toCharArray();
        long sum = 0;
        for(char i : s) {
            sum += (i - '0');
        }
        System.out.println(sum%9 == 0 ? "Yes" : "No");
        br.close();
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        char[] s = br.readLine().toCharArray();
        long sum = 0;
        for(char i : s) {
            sum += (i - '0');
        }
        System.out.println(sum%9 == 0 ? "Yes" : "No");
        br.close();
    }
} Main public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        char[] s = br.readLine().toCharArray();
        long sum = 0;
        for(char i : s) {
            sum += (i - '0');
        }
        System.out.println(sum%9 == 0 ? "Yes" : "No");
        br.close();
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        char[] s = br.readLine().toCharArray();
        long sum = 0;
        for(char i : s) {
            sum += (i - '0');
        }
        System.out.println(sum%9 == 0 ? "Yes" : "No");
        br.close();
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) char[] s = br.readLine().toCharArray(); s br.readLine().toCharArray() br.readLine().toCharArray br.readLine() br.readLine br long sum = 0; sum 0 for(char i : s) {
            sum += (i - '0');
        } char i s {
            sum += (i - '0');
        } {
            sum += (i - '0');
        } sum += (i - '0') sum (i - '0') i '0' 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" br.close() br.close br String[] args args public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        char[] s = br.readLine().toCharArray();
        long sum = 0;
        for(char i : s) {
            sum += (i - '0');
        }
        System.out.println(sum%9 == 0 ? "Yes" : "No");
        br.close();
    }
} public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        char[] s = br.readLine().toCharArray();
        long sum = 0;
        for(char i : s) {
            sum += (i - '0');
        }
        System.out.println(sum%9 == 0 ? "Yes" : "No");
        br.close();
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        char[] s = br.readLine().toCharArray();
        long sum = 0;
        for(char i : s) {
            sum += (i - '0');
        }
        System.out.println(sum%9 == 0 ? "Yes" : "No");
        br.close();
    }
}