import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Eric
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BMultipleOf9 solver = new BMultipleOf9();
        solver.solve(1, in, out);
        out.close();
    }

    static class BMultipleOf9 {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            String a = in.next();
            int res = 0;
            for (int i = 0; i < a.length(); i++) {
                int val = a.charAt(i) - '0';
                res += val;
                res %= 9;
            }
            out.print(((res == 0) ? "Yes" : "No"));
        }

    }

    static class FastReader {
        public BufferedReader br;
        public StringTokenizer st;
        String context = null;

        public FastReader(InputStream in) {
            this(new InputStreamReader(in));
        }

        public FastReader(InputStreamReader input) {
            br = new BufferedReader(input);
        }

        public String next() {
            if (context != null) {
                System.err.print("[" + context + "] Wait for input ...");
            }
            while (st == null || !st.hasMoreElements()) {
                try {
                    String s = br.readLine();
                    if (s == null)
                        return null;
                    st = new StringTokenizer(s);
                } catch (IOException e) {
                    e.printStackTrace();
                    throw new RuntimeException("Could not read");
                }
            }
            String res = st.nextToken();
            if (context != null) {
                System.err.println("[" + context + "] ... received : " + res);
            }
            return res;
        }

    }
}
 import java.io.OutputStream; OutputStream java.io import java.io.IOException; IOException java.io import java.io.InputStream; InputStream java.io import java.io.PrintWriter; PrintWriter java.io import java.io.PrintStream; PrintStream java.io import java.util.StringTokenizer; StringTokenizer java.util import java.io.IOException; IOException java.io import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.InputStream; InputStream java.io public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BMultipleOf9 solver = new BMultipleOf9();
        solver.solve(1, in, out);
        out.close();
    }

    static class BMultipleOf9 {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            String a = in.next();
            int res = 0;
            for (int i = 0; i < a.length(); i++) {
                int val = a.charAt(i) - '0';
                res += val;
                res %= 9;
            }
            out.print(((res == 0) ? "Yes" : "No"));
        }

    }

    static class FastReader {
        public BufferedReader br;
        public StringTokenizer st;
        String context = null;

        public FastReader(InputStream in) {
            this(new InputStreamReader(in));
        }

        public FastReader(InputStreamReader input) {
            br = new BufferedReader(input);
        }

        public String next() {
            if (context != null) {
                System.err.print("[" + context + "] Wait for input ...");
            }
            while (st == null || !st.hasMoreElements()) {
                try {
                    String s = br.readLine();
                    if (s == null)
                        return null;
                    st = new StringTokenizer(s);
                } catch (IOException e) {
                    e.printStackTrace();
                    throw new RuntimeException("Could not read");
                }
            }
            String res = st.nextToken();
            if (context != null) {
                System.err.println("[" + context + "] ... received : " + res);
            }
            return res;
        }

    }
} Main public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BMultipleOf9 solver = new BMultipleOf9();
        solver.solve(1, in, out);
        out.close();
    } main {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BMultipleOf9 solver = new BMultipleOf9();
        solver.solve(1, in, out);
        out.close();
    } InputStream inputStream = System.in; inputStream System.in System System.in OutputStream outputStream = System.out; outputStream System.out System System.out FastReader in = new FastReader(inputStream); in new FastReader(inputStream) PrintWriter out = new PrintWriter(outputStream); out new PrintWriter(outputStream) BMultipleOf9 solver = new BMultipleOf9(); solver new BMultipleOf9() solver.solve(1, in, out) solver.solve solver 1 in out out.close() out.close out String[] args args static class BMultipleOf9 {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            String a = in.next();
            int res = 0;
            for (int i = 0; i < a.length(); i++) {
                int val = a.charAt(i) - '0';
                res += val;
                res %= 9;
            }
            out.print(((res == 0) ? "Yes" : "No"));
        }

    } BMultipleOf9 public void solve(int testNumber, FastReader in, PrintWriter out) {
            String a = in.next();
            int res = 0;
            for (int i = 0; i < a.length(); i++) {
                int val = a.charAt(i) - '0';
                res += val;
                res %= 9;
            }
            out.print(((res == 0) ? "Yes" : "No"));
        } solve {
            String a = in.next();
            int res = 0;
            for (int i = 0; i < a.length(); i++) {
                int val = a.charAt(i) - '0';
                res += val;
                res %= 9;
            }
            out.print(((res == 0) ? "Yes" : "No"));
        } String a = in.next(); a in.next() in.next in int res = 0; res 0 for (int i = 0; i < a.length(); i++) {
                int val = a.charAt(i) - '0';
                res += val;
                res %= 9;
            } int i = 0; int i = 0; i 0 i < a.length() i a.length() a.length a i++ i++ i {
                int val = a.charAt(i) - '0';
                res += val;
                res %= 9;
            } {
                int val = a.charAt(i) - '0';
                res += val;
                res %= 9;
            } int val = a.charAt(i) - '0'; val a.charAt(i) - '0' a.charAt(i) a.charAt a i '0' res += val res val res %= 9 res 9 out.print(((res == 0) ? "Yes" : "No")) out.print out ((res == 0) ? "Yes" : "No") (res == 0) res 0 "Yes" "No" int testNumber testNumber FastReader in in PrintWriter out out static class FastReader {
        public BufferedReader br;
        public StringTokenizer st;
        String context = null;

        public FastReader(InputStream in) {
            this(new InputStreamReader(in));
        }

        public FastReader(InputStreamReader input) {
            br = new BufferedReader(input);
        }

        public String next() {
            if (context != null) {
                System.err.print("[" + context + "] Wait for input ...");
            }
            while (st == null || !st.hasMoreElements()) {
                try {
                    String s = br.readLine();
                    if (s == null)
                        return null;
                    st = new StringTokenizer(s);
                } catch (IOException e) {
                    e.printStackTrace();
                    throw new RuntimeException("Could not read");
                }
            }
            String res = st.nextToken();
            if (context != null) {
                System.err.println("[" + context + "] ... received : " + res);
            }
            return res;
        }

    } FastReader public BufferedReader br; br public StringTokenizer st; st String context = null; context null public FastReader(InputStream in) {
            this(new InputStreamReader(in));
        } FastReader {
            this(new InputStreamReader(in));
        } this(new InputStreamReader(in)) this new InputStreamReader(in) InputStream in in public FastReader(InputStreamReader input) {
            br = new BufferedReader(input);
        } FastReader {
            br = new BufferedReader(input);
        } br = new BufferedReader(input) br new BufferedReader(input) InputStreamReader input input public String next() {
            if (context != null) {
                System.err.print("[" + context + "] Wait for input ...");
            }
            while (st == null || !st.hasMoreElements()) {
                try {
                    String s = br.readLine();
                    if (s == null)
                        return null;
                    st = new StringTokenizer(s);
                } catch (IOException e) {
                    e.printStackTrace();
                    throw new RuntimeException("Could not read");
                }
            }
            String res = st.nextToken();
            if (context != null) {
                System.err.println("[" + context + "] ... received : " + res);
            }
            return res;
        } next {
            if (context != null) {
                System.err.print("[" + context + "] Wait for input ...");
            }
            while (st == null || !st.hasMoreElements()) {
                try {
                    String s = br.readLine();
                    if (s == null)
                        return null;
                    st = new StringTokenizer(s);
                } catch (IOException e) {
                    e.printStackTrace();
                    throw new RuntimeException("Could not read");
                }
            }
            String res = st.nextToken();
            if (context != null) {
                System.err.println("[" + context + "] ... received : " + res);
            }
            return res;
        } if (context != null) {
                System.err.print("[" + context + "] Wait for input ...");
            } context != null context null {
                System.err.print("[" + context + "] Wait for input ...");
            } System.err.print("[" + context + "] Wait for input ...") System.err.print System.err System System.err "[" + context + "] Wait for input ..." "[" + context + "] Wait for input ..." "[" context "] Wait for input ..." while (st == null || !st.hasMoreElements()) {
                try {
                    String s = br.readLine();
                    if (s == null)
                        return null;
                    st = new StringTokenizer(s);
                } catch (IOException e) {
                    e.printStackTrace();
                    throw new RuntimeException("Could not read");
                }
            } st == null || !st.hasMoreElements() st == null st null !st.hasMoreElements() st.hasMoreElements() st.hasMoreElements st {
                try {
                    String s = br.readLine();
                    if (s == null)
                        return null;
                    st = new StringTokenizer(s);
                } catch (IOException e) {
                    e.printStackTrace();
                    throw new RuntimeException("Could not read");
                }
            } try {
                    String s = br.readLine();
                    if (s == null)
                        return null;
                    st = new StringTokenizer(s);
                } catch (IOException e) {
                    e.printStackTrace();
                    throw new RuntimeException("Could not read");
                } catch (IOException e) {
                    e.printStackTrace();
                    throw new RuntimeException("Could not read");
                } IOException e {
                    e.printStackTrace();
                    throw new RuntimeException("Could not read");
                } e.printStackTrace() e.printStackTrace e throw new RuntimeException("Could not read"); new RuntimeException("Could not read") {
                    String s = br.readLine();
                    if (s == null)
                        return null;
                    st = new StringTokenizer(s);
                } String s = br.readLine(); s br.readLine() br.readLine br if (s == null)
                        return null; s == null s null return null; null st = new StringTokenizer(s) st new StringTokenizer(s) String res = st.nextToken(); res st.nextToken() st.nextToken st if (context != null) {
                System.err.println("[" + context + "] ... received : " + res);
            } context != null context null {
                System.err.println("[" + context + "] ... received : " + res);
            } System.err.println("[" + context + "] ... received : " + res) System.err.println System.err System System.err "[" + context + "] ... received : " + res "] ... received : " "[" + context + "] ... received : " + res "[" context "] ... received : " res return res; res public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BMultipleOf9 solver = new BMultipleOf9();
        solver.solve(1, in, out);
        out.close();
    }

    static class BMultipleOf9 {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            String a = in.next();
            int res = 0;
            for (int i = 0; i < a.length(); i++) {
                int val = a.charAt(i) - '0';
                res += val;
                res %= 9;
            }
            out.print(((res == 0) ? "Yes" : "No"));
        }

    }

    static class FastReader {
        public BufferedReader br;
        public StringTokenizer st;
        String context = null;

        public FastReader(InputStream in) {
            this(new InputStreamReader(in));
        }

        public FastReader(InputStreamReader input) {
            br = new BufferedReader(input);
        }

        public String next() {
            if (context != null) {
                System.err.print("[" + context + "] Wait for input ...");
            }
            while (st == null || !st.hasMoreElements()) {
                try {
                    String s = br.readLine();
                    if (s == null)
                        return null;
                    st = new StringTokenizer(s);
                } catch (IOException e) {
                    e.printStackTrace();
                    throw new RuntimeException("Could not read");
                }
            }
            String res = st.nextToken();
            if (context != null) {
                System.err.println("[" + context + "] ... received : " + res);
            }
            return res;
        }

    }
} public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BMultipleOf9 solver = new BMultipleOf9();
        solver.solve(1, in, out);
        out.close();
    }

    static class BMultipleOf9 {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            String a = in.next();
            int res = 0;
            for (int i = 0; i < a.length(); i++) {
                int val = a.charAt(i) - '0';
                res += val;
                res %= 9;
            }
            out.print(((res == 0) ? "Yes" : "No"));
        }

    }

    static class FastReader {
        public BufferedReader br;
        public StringTokenizer st;
        String context = null;

        public FastReader(InputStream in) {
            this(new InputStreamReader(in));
        }

        public FastReader(InputStreamReader input) {
            br = new BufferedReader(input);
        }

        public String next() {
            if (context != null) {
                System.err.print("[" + context + "] Wait for input ...");
            }
            while (st == null || !st.hasMoreElements()) {
                try {
                    String s = br.readLine();
                    if (s == null)
                        return null;
                    st = new StringTokenizer(s);
                } catch (IOException e) {
                    e.printStackTrace();
                    throw new RuntimeException("Could not read");
                }
            }
            String res = st.nextToken();
            if (context != null) {
                System.err.println("[" + context + "] ... received : " + res);
            }
            return res;
        }

    }
} Main
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Eric
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BMultipleOf9 solver = new BMultipleOf9();
        solver.solve(1, in, out);
        out.close();
    }

    static class BMultipleOf9 {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            String a = in.next();
            int res = 0;
            for (int i = 0; i < a.length(); i++) {
                int val = a.charAt(i) - '0';
                res += val;
                res %= 9;
            }
            out.print(((res == 0) ? "Yes" : "No"));
        }

    }

    static class FastReader {
        public BufferedReader br;
        public StringTokenizer st;
        String context = null;

        public FastReader(InputStream in) {
            this(new InputStreamReader(in));
        }

        public FastReader(InputStreamReader input) {
            br = new BufferedReader(input);
        }

        public String next() {
            if (context != null) {
                System.err.print("[" + context + "] Wait for input ...");
            }
            while (st == null || !st.hasMoreElements()) {
                try {
                    String s = br.readLine();
                    if (s == null)
                        return null;
                    st = new StringTokenizer(s);
                } catch (IOException e) {
                    e.printStackTrace();
                    throw new RuntimeException("Could not read");
                }
            }
            String res = st.nextToken();
            if (context != null) {
                System.err.println("[" + context + "] ... received : " + res);
            }
            return res;
        }

    }
}

