import java.io.*;

public class Main {

    public static void main(String[] args) throws IOException {
        PrintWriter prnt = new PrintWriter(System.out);
        BufferedReader read = new BufferedReader(new InputStreamReader(System.in));

        String s = read.readLine();

        if (isMultipleOFNine(s)) {
            prnt.println("Yes");
        } else {
            prnt.println("No");
        }
        prnt.close();
    }

    static boolean isMultipleOFNine(String s) {
        char[] digits = s.toCharArray();
        long N = 0;
        for (int i = 0; i < digits.length; i++) {
            N += (digits[i] - '0');
        }
        if (N % 9 == 0) return true;
        else return false;
    }
} import java.io.*; io.* java public class Main {

    public static void main(String[] args) throws IOException {
        PrintWriter prnt = new PrintWriter(System.out);
        BufferedReader read = new BufferedReader(new InputStreamReader(System.in));

        String s = read.readLine();

        if (isMultipleOFNine(s)) {
            prnt.println("Yes");
        } else {
            prnt.println("No");
        }
        prnt.close();
    }

    static boolean isMultipleOFNine(String s) {
        char[] digits = s.toCharArray();
        long N = 0;
        for (int i = 0; i < digits.length; i++) {
            N += (digits[i] - '0');
        }
        if (N % 9 == 0) return true;
        else return false;
    }
} Main public static void main(String[] args) throws IOException {
        PrintWriter prnt = new PrintWriter(System.out);
        BufferedReader read = new BufferedReader(new InputStreamReader(System.in));

        String s = read.readLine();

        if (isMultipleOFNine(s)) {
            prnt.println("Yes");
        } else {
            prnt.println("No");
        }
        prnt.close();
    } main {
        PrintWriter prnt = new PrintWriter(System.out);
        BufferedReader read = new BufferedReader(new InputStreamReader(System.in));

        String s = read.readLine();

        if (isMultipleOFNine(s)) {
            prnt.println("Yes");
        } else {
            prnt.println("No");
        }
        prnt.close();
    } PrintWriter prnt = new PrintWriter(System.out); prnt new PrintWriter(System.out) BufferedReader read = new BufferedReader(new InputStreamReader(System.in)); read new BufferedReader(new InputStreamReader(System.in)) String s = read.readLine(); s read.readLine() read.readLine read if (isMultipleOFNine(s)) {
            prnt.println("Yes");
        } else {
            prnt.println("No");
        } isMultipleOFNine(s) isMultipleOFNine s {
            prnt.println("Yes");
        } prnt.println("Yes") prnt.println prnt "Yes" {
            prnt.println("No");
        } prnt.println("No") prnt.println prnt "No" prnt.close() prnt.close prnt String[] args args static boolean isMultipleOFNine(String s) {
        char[] digits = s.toCharArray();
        long N = 0;
        for (int i = 0; i < digits.length; i++) {
            N += (digits[i] - '0');
        }
        if (N % 9 == 0) return true;
        else return false;
    } isMultipleOFNine {
        char[] digits = s.toCharArray();
        long N = 0;
        for (int i = 0; i < digits.length; i++) {
            N += (digits[i] - '0');
        }
        if (N % 9 == 0) return true;
        else return false;
    } char[] digits = s.toCharArray(); digits s.toCharArray() s.toCharArray s long N = 0; N 0 for (int i = 0; i < digits.length; i++) {
            N += (digits[i] - '0');
        } int i = 0; int i = 0; i 0 i < digits.length i digits.length digits digits.length i++ i++ i {
            N += (digits[i] - '0');
        } {
            N += (digits[i] - '0');
        } N += (digits[i] - '0') N (digits[i] - '0') digits[i] digits i '0' if (N % 9 == 0) return true;
        else return false; N % 9 == 0 N % 9 N 9 0 return true; true return false; false String s s public class Main {

    public static void main(String[] args) throws IOException {
        PrintWriter prnt = new PrintWriter(System.out);
        BufferedReader read = new BufferedReader(new InputStreamReader(System.in));

        String s = read.readLine();

        if (isMultipleOFNine(s)) {
            prnt.println("Yes");
        } else {
            prnt.println("No");
        }
        prnt.close();
    }

    static boolean isMultipleOFNine(String s) {
        char[] digits = s.toCharArray();
        long N = 0;
        for (int i = 0; i < digits.length; i++) {
            N += (digits[i] - '0');
        }
        if (N % 9 == 0) return true;
        else return false;
    }
} public class Main {

    public static void main(String[] args) throws IOException {
        PrintWriter prnt = new PrintWriter(System.out);
        BufferedReader read = new BufferedReader(new InputStreamReader(System.in));

        String s = read.readLine();

        if (isMultipleOFNine(s)) {
            prnt.println("Yes");
        } else {
            prnt.println("No");
        }
        prnt.close();
    }

    static boolean isMultipleOFNine(String s) {
        char[] digits = s.toCharArray();
        long N = 0;
        for (int i = 0; i < digits.length; i++) {
            N += (digits[i] - '0');
        }
        if (N % 9 == 0) return true;
        else return false;
    }
} Main
import java.io.*;

public class Main {

    public static void main(String[] args) throws IOException {
        PrintWriter prnt = new PrintWriter(System.out);
        BufferedReader read = new BufferedReader(new InputStreamReader(System.in));

        String s = read.readLine();

        if (isMultipleOFNine(s)) {
            prnt.println("Yes");
        } else {
            prnt.println("No");
        }
        prnt.close();
    }

    static boolean isMultipleOFNine(String s) {
        char[] digits = s.toCharArray();
        long N = 0;
        for (int i = 0; i < digits.length; i++) {
            N += (digits[i] - '0');
        }
        if (N % 9 == 0) return true;
        else return false;
    }
}