
import java.io.*;
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

/**
 * @author AnonymousP
 * @__WHEN YOU FEEL LIKE QUITTING, THINK ABOUT WHY YOU STARTED__@
 */
//COMBINATON = nCr = n*(n-1)/2
public class Main {

    public static void main(String[] args) throws IOException {

        String s = sc.next();

        char c[] = s.toCharArray();
        int sum = 0;
        for (int i = 0; i < c.length; i++) {
            sum += (c[i] - '0');
        }
        prln((sum % 9 == 0) ? "Yes" : "No");
        close();
    }

    static FastReader sc = new FastReader();
    static PrintWriter __out = new PrintWriter(new OutputStreamWriter(System.out));
    static StringTokenizer input;
    static Random __rand = new Random();

    // input
    //*******FAST IO*************FAST IO***************FAST IO****************//
    static class FastReader {

        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
// output

    static void pr(int i) {
        __out.print(i);
    }

    static void prln(int i) {
        __out.println(i);
    }

    static void pr(long l) {
        __out.print(l);
    }

    static void prln(long l) {
        __out.println(l);
    }

    static void pr(double d) {
        __out.print(d);
    }

    static void prln(double d) {
        __out.println(d);
    }

    static void pr(char c) {
        __out.print(c);
    }

    static void prln(char c) {
        __out.println(c);
    }

    static void pr(char[] s) {
        __out.print(new String(s));
    }

    static void prln(char[] s) {
        __out.println(new String(s));
    }

    static void pr(String s) {
        __out.print(s);
    }

    static void prln(String s) {
        __out.println(s);
    }

    static void pr(Object o) {
        __out.print(o);
    }

    static void prln(Object o) {
        __out.println(o);
    }

    static void prln() {
        __out.println();
    }

    static void pryes() {
        __out.println("yes");
    }

    static void pry() {
        __out.println("Yes");
    }

    static void prY() {
        __out.println("YES");
    }

    static void prno() {
        __out.println("no");
    }

    static void prn() {
        __out.println("No");
    }

    static void prN() {
        __out.println("NO");
    }

    static void pryesno(boolean b) {
        __out.println(b ? "yes" : "no");
    }

    ;
    static void pryn(boolean b) {
        __out.println(b ? "Yes" : "No");
    }

    static void prYN(boolean b) {
        __out.println(b ? "YES" : "NO");
    }

    static void prln(int... a) {
        for (int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), ++i);
        __out.println(a[a.length - 1]);
    }

    static void prln(long... a) {
        for (int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), ++i);
        __out.println(a[a.length - 1]);
    }

    static <T> void prln(Collection<T> c) {
        int n = c.size() - 1;
        Iterator<T> iter = c.iterator();
        for (int i = 0; i < n; __out.print(iter.next()), __out.print(' '), ++i);
        if (n >= 0) {
            __out.println(iter.next());
        } else {
            __out.println();
        }
    }

    static void h() {
        __out.println("hlfd");
        flush();
    }

    static void flush() {
        __out.flush();
    }

    static void close() {
        __out.close();
    }
} import java.io.*; io.* java import java.util.*; util.* java import static java.lang.Math.*; import static java.lang.Math.*; import static java.lang.Math.*; import static java.util.Arrays.*; import static java.util.Arrays.*; import static java.util.Arrays.*; public class Main {

    public static void main(String[] args) throws IOException {

        String s = sc.next();

        char c[] = s.toCharArray();
        int sum = 0;
        for (int i = 0; i < c.length; i++) {
            sum += (c[i] - '0');
        }
        prln((sum % 9 == 0) ? "Yes" : "No");
        close();
    }

    static FastReader sc = new FastReader();
    static PrintWriter __out = new PrintWriter(new OutputStreamWriter(System.out));
    static StringTokenizer input;
    static Random __rand = new Random();

    // input
    //*******FAST IO*************FAST IO***************FAST IO****************//
    static class FastReader {

        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
// output

    static void pr(int i) {
        __out.print(i);
    }

    static void prln(int i) {
        __out.println(i);
    }

    static void pr(long l) {
        __out.print(l);
    }

    static void prln(long l) {
        __out.println(l);
    }

    static void pr(double d) {
        __out.print(d);
    }

    static void prln(double d) {
        __out.println(d);
    }

    static void pr(char c) {
        __out.print(c);
    }

    static void prln(char c) {
        __out.println(c);
    }

    static void pr(char[] s) {
        __out.print(new String(s));
    }

    static void prln(char[] s) {
        __out.println(new String(s));
    }

    static void pr(String s) {
        __out.print(s);
    }

    static void prln(String s) {
        __out.println(s);
    }

    static void pr(Object o) {
        __out.print(o);
    }

    static void prln(Object o) {
        __out.println(o);
    }

    static void prln() {
        __out.println();
    }

    static void pryes() {
        __out.println("yes");
    }

    static void pry() {
        __out.println("Yes");
    }

    static void prY() {
        __out.println("YES");
    }

    static void prno() {
        __out.println("no");
    }

    static void prn() {
        __out.println("No");
    }

    static void prN() {
        __out.println("NO");
    }

    static void pryesno(boolean b) {
        __out.println(b ? "yes" : "no");
    }

    ;
    static void pryn(boolean b) {
        __out.println(b ? "Yes" : "No");
    }

    static void prYN(boolean b) {
        __out.println(b ? "YES" : "NO");
    }

    static void prln(int... a) {
        for (int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), ++i);
        __out.println(a[a.length - 1]);
    }

    static void prln(long... a) {
        for (int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), ++i);
        __out.println(a[a.length - 1]);
    }

    static <T> void prln(Collection<T> c) {
        int n = c.size() - 1;
        Iterator<T> iter = c.iterator();
        for (int i = 0; i < n; __out.print(iter.next()), __out.print(' '), ++i);
        if (n >= 0) {
            __out.println(iter.next());
        } else {
            __out.println();
        }
    }

    static void h() {
        __out.println("hlfd");
        flush();
    }

    static void flush() {
        __out.flush();
    }

    static void close() {
        __out.close();
    }
} Main static FastReader sc = new FastReader(); sc new FastReader() static PrintWriter __out = new PrintWriter(new OutputStreamWriter(System.out)); __out new PrintWriter(new OutputStreamWriter(System.out)) static StringTokenizer input; input static Random __rand = new Random(); __rand new Random() public static void main(String[] args) throws IOException {

        String s = sc.next();

        char c[] = s.toCharArray();
        int sum = 0;
        for (int i = 0; i < c.length; i++) {
            sum += (c[i] - '0');
        }
        prln((sum % 9 == 0) ? "Yes" : "No");
        close();
    } main {

        String s = sc.next();

        char c[] = s.toCharArray();
        int sum = 0;
        for (int i = 0; i < c.length; i++) {
            sum += (c[i] - '0');
        }
        prln((sum % 9 == 0) ? "Yes" : "No");
        close();
    } String s = sc.next(); s sc.next() sc.next sc char c[] = s.toCharArray(); c s.toCharArray() s.toCharArray s int sum = 0; sum 0 for (int i = 0; i < c.length; i++) {
            sum += (c[i] - '0');
        } int i = 0; int i = 0; i 0 i < c.length i c.length c c.length i++ i++ i {
            sum += (c[i] - '0');
        } {
            sum += (c[i] - '0');
        } sum += (c[i] - '0') sum (c[i] - '0') c[i] c i '0' prln((sum % 9 == 0) ? "Yes" : "No") prln (sum % 9 == 0) ? "Yes" : "No" (sum % 9 == 0) sum % 9 sum 9 0 "Yes" "No" close() close String[] args args static void pr(int i) {
        __out.print(i);
    } pr {
        __out.print(i);
    } __out.print(i) __out.print __out i int i i static void prln(int i) {
        __out.println(i);
    } prln {
        __out.println(i);
    } __out.println(i) __out.println __out i int i i static void pr(long l) {
        __out.print(l);
    } pr {
        __out.print(l);
    } __out.print(l) __out.print __out l long l l static void prln(long l) {
        __out.println(l);
    } prln {
        __out.println(l);
    } __out.println(l) __out.println __out l long l l static void pr(double d) {
        __out.print(d);
    } pr {
        __out.print(d);
    } __out.print(d) __out.print __out d double d d static void prln(double d) {
        __out.println(d);
    } prln {
        __out.println(d);
    } __out.println(d) __out.println __out d double d d static void pr(char c) {
        __out.print(c);
    } pr {
        __out.print(c);
    } __out.print(c) __out.print __out c char c c static void prln(char c) {
        __out.println(c);
    } prln {
        __out.println(c);
    } __out.println(c) __out.println __out c char c c static void pr(char[] s) {
        __out.print(new String(s));
    } pr {
        __out.print(new String(s));
    } __out.print(new String(s)) __out.print __out new String(s) char[] s s static void prln(char[] s) {
        __out.println(new String(s));
    } prln {
        __out.println(new String(s));
    } __out.println(new String(s)) __out.println __out new String(s) char[] s s static void pr(String s) {
        __out.print(s);
    } pr {
        __out.print(s);
    } __out.print(s) __out.print __out s String s s static void prln(String s) {
        __out.println(s);
    } prln {
        __out.println(s);
    } __out.println(s) __out.println __out s String s s static void pr(Object o) {
        __out.print(o);
    } pr {
        __out.print(o);
    } __out.print(o) __out.print __out o Object o o static void prln(Object o) {
        __out.println(o);
    } prln {
        __out.println(o);
    } __out.println(o) __out.println __out o Object o o static void prln() {
        __out.println();
    } prln {
        __out.println();
    } __out.println() __out.println __out static void pryes() {
        __out.println("yes");
    } pryes {
        __out.println("yes");
    } __out.println("yes") __out.println __out "yes" static void pry() {
        __out.println("Yes");
    } pry {
        __out.println("Yes");
    } __out.println("Yes") __out.println __out "Yes" static void prY() {
        __out.println("YES");
    } prY {
        __out.println("YES");
    } __out.println("YES") __out.println __out "YES" static void prno() {
        __out.println("no");
    } prno {
        __out.println("no");
    } __out.println("no") __out.println __out "no" static void prn() {
        __out.println("No");
    } prn {
        __out.println("No");
    } __out.println("No") __out.println __out "No" static void prN() {
        __out.println("NO");
    } prN {
        __out.println("NO");
    } __out.println("NO") __out.println __out "NO" static void pryesno(boolean b) {
        __out.println(b ? "yes" : "no");
    } pryesno {
        __out.println(b ? "yes" : "no");
    } __out.println(b ? "yes" : "no") __out.println __out b ? "yes" : "no" b "yes" "no" boolean b b static void pryn(boolean b) {
        __out.println(b ? "Yes" : "No");
    } pryn {
        __out.println(b ? "Yes" : "No");
    } __out.println(b ? "Yes" : "No") __out.println __out b ? "Yes" : "No" b "Yes" "No" boolean b b static void prYN(boolean b) {
        __out.println(b ? "YES" : "NO");
    } prYN {
        __out.println(b ? "YES" : "NO");
    } __out.println(b ? "YES" : "NO") __out.println __out b ? "YES" : "NO" b "YES" "NO" boolean b b static void prln(int... a) {
        for (int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), ++i);
        __out.println(a[a.length - 1]);
    } prln {
        for (int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), ++i);
        __out.println(a[a.length - 1]);
    } for (int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), ++i); int i = 0, len = a.length - 1; int i = 0 i 0 len = a.length - 1; len a.length - 1 a.length a a.length 1 i < len i len __out.print(a[i]), __out.print(' '), ++i __out.print(a[i]) __out.print __out a[i] a i __out.print(' ') __out.print __out ' ' ++i i ; __out.println(a[a.length - 1]) __out.println __out a[a.length - 1] a a.length - 1 a.length a a.length 1 int... a a static void prln(long... a) {
        for (int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), ++i);
        __out.println(a[a.length - 1]);
    } prln {
        for (int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), ++i);
        __out.println(a[a.length - 1]);
    } for (int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), ++i); int i = 0, len = a.length - 1; int i = 0 i 0 len = a.length - 1; len a.length - 1 a.length a a.length 1 i < len i len __out.print(a[i]), __out.print(' '), ++i __out.print(a[i]) __out.print __out a[i] a i __out.print(' ') __out.print __out ' ' ++i i ; __out.println(a[a.length - 1]) __out.println __out a[a.length - 1] a a.length - 1 a.length a a.length 1 long... a a static <T> void prln(Collection<T> c) {
        int n = c.size() - 1;
        Iterator<T> iter = c.iterator();
        for (int i = 0; i < n; __out.print(iter.next()), __out.print(' '), ++i);
        if (n >= 0) {
            __out.println(iter.next());
        } else {
            __out.println();
        }
    } prln {
        int n = c.size() - 1;
        Iterator<T> iter = c.iterator();
        for (int i = 0; i < n; __out.print(iter.next()), __out.print(' '), ++i);
        if (n >= 0) {
            __out.println(iter.next());
        } else {
            __out.println();
        }
    } int n = c.size() - 1; n c.size() - 1 c.size() c.size c 1 Iterator<T> iter = c.iterator(); iter c.iterator() c.iterator c for (int i = 0; i < n; __out.print(iter.next()), __out.print(' '), ++i); int i = 0; int i = 0; i 0 i < n i n __out.print(iter.next()), __out.print(' '), ++i __out.print(iter.next()) __out.print __out iter.next() iter.next iter __out.print(' ') __out.print __out ' ' ++i i ; if (n >= 0) {
            __out.println(iter.next());
        } else {
            __out.println();
        } n >= 0 n 0 {
            __out.println(iter.next());
        } __out.println(iter.next()) __out.println __out iter.next() iter.next iter {
            __out.println();
        } __out.println() __out.println __out Collection<T> c c static void h() {
        __out.println("hlfd");
        flush();
    } h {
        __out.println("hlfd");
        flush();
    } __out.println("hlfd") __out.println __out "hlfd" flush() flush static void flush() {
        __out.flush();
    } flush {
        __out.flush();
    } __out.flush() __out.flush __out static void close() {
        __out.close();
    } close {
        __out.close();
    } __out.close() __out.close __out static class FastReader {

        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    } FastReader BufferedReader br; br StringTokenizer st; st public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        } FastReader {
            br = new BufferedReader(new InputStreamReader(System.in));
        } br = new BufferedReader(new InputStreamReader(System.in)) br new BufferedReader(new InputStreamReader(System.in)) String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        } next {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        } while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            } st == null || !st.hasMoreElements() st == null st null !st.hasMoreElements() st.hasMoreElements() st.hasMoreElements st {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            } try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                } IOException e {
                    e.printStackTrace();
                } e.printStackTrace() e.printStackTrace e {
                    st = new StringTokenizer(br.readLine());
                } st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) return st.nextToken(); st.nextToken() st.nextToken st int nextInt() {
            return Integer.parseInt(next());
        } nextInt {
            return Integer.parseInt(next());
        } return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next long nextLong() {
            return Long.parseLong(next());
        } nextLong {
            return Long.parseLong(next());
        } return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next double nextDouble() {
            return Double.parseDouble(next());
        } nextDouble {
            return Double.parseDouble(next());
        } return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        } nextLine {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        } String str = ""; str "" try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            } IOException e {
                e.printStackTrace();
            } e.printStackTrace() e.printStackTrace e {
                str = br.readLine();
            } str = br.readLine() str br.readLine() br.readLine br return str; str public class Main {

    public static void main(String[] args) throws IOException {

        String s = sc.next();

        char c[] = s.toCharArray();
        int sum = 0;
        for (int i = 0; i < c.length; i++) {
            sum += (c[i] - '0');
        }
        prln((sum % 9 == 0) ? "Yes" : "No");
        close();
    }

    static FastReader sc = new FastReader();
    static PrintWriter __out = new PrintWriter(new OutputStreamWriter(System.out));
    static StringTokenizer input;
    static Random __rand = new Random();

    // input
    //*******FAST IO*************FAST IO***************FAST IO****************//
    static class FastReader {

        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
// output

    static void pr(int i) {
        __out.print(i);
    }

    static void prln(int i) {
        __out.println(i);
    }

    static void pr(long l) {
        __out.print(l);
    }

    static void prln(long l) {
        __out.println(l);
    }

    static void pr(double d) {
        __out.print(d);
    }

    static void prln(double d) {
        __out.println(d);
    }

    static void pr(char c) {
        __out.print(c);
    }

    static void prln(char c) {
        __out.println(c);
    }

    static void pr(char[] s) {
        __out.print(new String(s));
    }

    static void prln(char[] s) {
        __out.println(new String(s));
    }

    static void pr(String s) {
        __out.print(s);
    }

    static void prln(String s) {
        __out.println(s);
    }

    static void pr(Object o) {
        __out.print(o);
    }

    static void prln(Object o) {
        __out.println(o);
    }

    static void prln() {
        __out.println();
    }

    static void pryes() {
        __out.println("yes");
    }

    static void pry() {
        __out.println("Yes");
    }

    static void prY() {
        __out.println("YES");
    }

    static void prno() {
        __out.println("no");
    }

    static void prn() {
        __out.println("No");
    }

    static void prN() {
        __out.println("NO");
    }

    static void pryesno(boolean b) {
        __out.println(b ? "yes" : "no");
    }

    ;
    static void pryn(boolean b) {
        __out.println(b ? "Yes" : "No");
    }

    static void prYN(boolean b) {
        __out.println(b ? "YES" : "NO");
    }

    static void prln(int... a) {
        for (int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), ++i);
        __out.println(a[a.length - 1]);
    }

    static void prln(long... a) {
        for (int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), ++i);
        __out.println(a[a.length - 1]);
    }

    static <T> void prln(Collection<T> c) {
        int n = c.size() - 1;
        Iterator<T> iter = c.iterator();
        for (int i = 0; i < n; __out.print(iter.next()), __out.print(' '), ++i);
        if (n >= 0) {
            __out.println(iter.next());
        } else {
            __out.println();
        }
    }

    static void h() {
        __out.println("hlfd");
        flush();
    }

    static void flush() {
        __out.flush();
    }

    static void close() {
        __out.close();
    }
} public class Main {

    public static void main(String[] args) throws IOException {

        String s = sc.next();

        char c[] = s.toCharArray();
        int sum = 0;
        for (int i = 0; i < c.length; i++) {
            sum += (c[i] - '0');
        }
        prln((sum % 9 == 0) ? "Yes" : "No");
        close();
    }

    static FastReader sc = new FastReader();
    static PrintWriter __out = new PrintWriter(new OutputStreamWriter(System.out));
    static StringTokenizer input;
    static Random __rand = new Random();

    // input
    //*******FAST IO*************FAST IO***************FAST IO****************//
    static class FastReader {

        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
// output

    static void pr(int i) {
        __out.print(i);
    }

    static void prln(int i) {
        __out.println(i);
    }

    static void pr(long l) {
        __out.print(l);
    }

    static void prln(long l) {
        __out.println(l);
    }

    static void pr(double d) {
        __out.print(d);
    }

    static void prln(double d) {
        __out.println(d);
    }

    static void pr(char c) {
        __out.print(c);
    }

    static void prln(char c) {
        __out.println(c);
    }

    static void pr(char[] s) {
        __out.print(new String(s));
    }

    static void prln(char[] s) {
        __out.println(new String(s));
    }

    static void pr(String s) {
        __out.print(s);
    }

    static void prln(String s) {
        __out.println(s);
    }

    static void pr(Object o) {
        __out.print(o);
    }

    static void prln(Object o) {
        __out.println(o);
    }

    static void prln() {
        __out.println();
    }

    static void pryes() {
        __out.println("yes");
    }

    static void pry() {
        __out.println("Yes");
    }

    static void prY() {
        __out.println("YES");
    }

    static void prno() {
        __out.println("no");
    }

    static void prn() {
        __out.println("No");
    }

    static void prN() {
        __out.println("NO");
    }

    static void pryesno(boolean b) {
        __out.println(b ? "yes" : "no");
    }

    ;
    static void pryn(boolean b) {
        __out.println(b ? "Yes" : "No");
    }

    static void prYN(boolean b) {
        __out.println(b ? "YES" : "NO");
    }

    static void prln(int... a) {
        for (int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), ++i);
        __out.println(a[a.length - 1]);
    }

    static void prln(long... a) {
        for (int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), ++i);
        __out.println(a[a.length - 1]);
    }

    static <T> void prln(Collection<T> c) {
        int n = c.size() - 1;
        Iterator<T> iter = c.iterator();
        for (int i = 0; i < n; __out.print(iter.next()), __out.print(' '), ++i);
        if (n >= 0) {
            __out.println(iter.next());
        } else {
            __out.println();
        }
    }

    static void h() {
        __out.println("hlfd");
        flush();
    }

    static void flush() {
        __out.flush();
    }

    static void close() {
        __out.close();
    }
} Main

import java.io.*;
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

/**
 * @author AnonymousP
 * @__WHEN YOU FEEL LIKE QUITTING, THINK ABOUT WHY YOU STARTED__@
 */
//COMBINATON = nCr = n*(n-1)/2
public class Main {

    public static void main(String[] args) throws IOException {

        String s = sc.next();

        char c[] = s.toCharArray();
        int sum = 0;
        for (int i = 0; i < c.length; i++) {
            sum += (c[i] - '0');
        }
        prln((sum % 9 == 0) ? "Yes" : "No");
        close();
    }

    static FastReader sc = new FastReader();
    static PrintWriter __out = new PrintWriter(new OutputStreamWriter(System.out));
    static StringTokenizer input;
    static Random __rand = new Random();

    // input
    //*******FAST IO*************FAST IO***************FAST IO****************//
    static class FastReader {

        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
// output

    static void pr(int i) {
        __out.print(i);
    }

    static void prln(int i) {
        __out.println(i);
    }

    static void pr(long l) {
        __out.print(l);
    }

    static void prln(long l) {
        __out.println(l);
    }

    static void pr(double d) {
        __out.print(d);
    }

    static void prln(double d) {
        __out.println(d);
    }

    static void pr(char c) {
        __out.print(c);
    }

    static void prln(char c) {
        __out.println(c);
    }

    static void pr(char[] s) {
        __out.print(new String(s));
    }

    static void prln(char[] s) {
        __out.println(new String(s));
    }

    static void pr(String s) {
        __out.print(s);
    }

    static void prln(String s) {
        __out.println(s);
    }

    static void pr(Object o) {
        __out.print(o);
    }

    static void prln(Object o) {
        __out.println(o);
    }

    static void prln() {
        __out.println();
    }

    static void pryes() {
        __out.println("yes");
    }

    static void pry() {
        __out.println("Yes");
    }

    static void prY() {
        __out.println("YES");
    }

    static void prno() {
        __out.println("no");
    }

    static void prn() {
        __out.println("No");
    }

    static void prN() {
        __out.println("NO");
    }

    static void pryesno(boolean b) {
        __out.println(b ? "yes" : "no");
    }

    ;
    static void pryn(boolean b) {
        __out.println(b ? "Yes" : "No");
    }

    static void prYN(boolean b) {
        __out.println(b ? "YES" : "NO");
    }

    static void prln(int... a) {
        for (int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), ++i);
        __out.println(a[a.length - 1]);
    }

    static void prln(long... a) {
        for (int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), ++i);
        __out.println(a[a.length - 1]);
    }

    static <T> void prln(Collection<T> c) {
        int n = c.size() - 1;
        Iterator<T> iter = c.iterator();
        for (int i = 0; i < n; __out.print(iter.next()), __out.print(' '), ++i);
        if (n >= 0) {
            __out.println(iter.next());
        } else {
            __out.println();
        }
    }

    static void h() {
        __out.println("hlfd");
        flush();
    }

    static void flush() {
        __out.flush();
    }

    static void close() {
        __out.close();
    }
}
