import java.io.*;
import java.util.*;

public class Main {
    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static StringTokenizer st;

    public static void main(String[] args) throws IOException {
        char[] cs = br.readLine().toCharArray();

        int ds = 0;
        for (char c : cs) {
            ds += c;
        }
        ds -= cs.length * '0';
        System.out.println(ds % 9 == 0 ? "Yes" : "No");
    }
} import java.io.*; io.* java import java.util.*; util.* java public class Main {
    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static StringTokenizer st;

    public static void main(String[] args) throws IOException {
        char[] cs = br.readLine().toCharArray();

        int ds = 0;
        for (char c : cs) {
            ds += c;
        }
        ds -= cs.length * '0';
        System.out.println(ds % 9 == 0 ? "Yes" : "No");
    }
} Main private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) private static StringTokenizer st; st public static void main(String[] args) throws IOException {
        char[] cs = br.readLine().toCharArray();

        int ds = 0;
        for (char c : cs) {
            ds += c;
        }
        ds -= cs.length * '0';
        System.out.println(ds % 9 == 0 ? "Yes" : "No");
    } main {
        char[] cs = br.readLine().toCharArray();

        int ds = 0;
        for (char c : cs) {
            ds += c;
        }
        ds -= cs.length * '0';
        System.out.println(ds % 9 == 0 ? "Yes" : "No");
    } char[] cs = br.readLine().toCharArray(); cs br.readLine().toCharArray() br.readLine().toCharArray br.readLine() br.readLine br int ds = 0; ds 0 for (char c : cs) {
            ds += c;
        } char c cs {
            ds += c;
        } {
            ds += c;
        } ds += c ds c ds -= cs.length * '0' ds cs.length * '0' cs.length cs cs.length '0' System.out.println(ds % 9 == 0 ? "Yes" : "No") System.out.println System.out System System.out ds % 9 == 0 ? "Yes" : "No" ds % 9 == 0 ds % 9 ds 9 0 "Yes" "No" String[] args args public class Main {
    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static StringTokenizer st;

    public static void main(String[] args) throws IOException {
        char[] cs = br.readLine().toCharArray();

        int ds = 0;
        for (char c : cs) {
            ds += c;
        }
        ds -= cs.length * '0';
        System.out.println(ds % 9 == 0 ? "Yes" : "No");
    }
} public class Main {
    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static StringTokenizer st;

    public static void main(String[] args) throws IOException {
        char[] cs = br.readLine().toCharArray();

        int ds = 0;
        for (char c : cs) {
            ds += c;
        }
        ds -= cs.length * '0';
        System.out.println(ds % 9 == 0 ? "Yes" : "No");
    }
} Main
import java.io.*;
import java.util.*;

public class Main {
    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static StringTokenizer st;

    public static void main(String[] args) throws IOException {
        char[] cs = br.readLine().toCharArray();

        int ds = 0;
        for (char c : cs) {
            ds += c;
        }
        ds -= cs.length * '0';
        System.out.println(ds % 9 == 0 ? "Yes" : "No");
    }
}
