import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.util.Arrays;
import java.lang.Math;

public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        String x = fs.next();
        char[] xx = x.toCharArray();

        ArrayList<Integer> summer = new ArrayList<>();

        for (int i = 0; i<xx.length;i++) {
            summer.add((int) xx[i]-48);
        }

        int sum =0;
        for (int i = 0; i<summer.size(); i++) {
            sum+=summer.get(i);
        }
        if (sum % 9 == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }




    }


    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");

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

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

        int[] readArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }
    }

}
 import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayList; ArrayList java.util import java.util.StringTokenizer; StringTokenizer java.util import java.util.Arrays; Arrays java.util import java.lang.Math; Math java.lang public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        String x = fs.next();
        char[] xx = x.toCharArray();

        ArrayList<Integer> summer = new ArrayList<>();

        for (int i = 0; i<xx.length;i++) {
            summer.add((int) xx[i]-48);
        }

        int sum =0;
        for (int i = 0; i<summer.size(); i++) {
            sum+=summer.get(i);
        }
        if (sum % 9 == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }




    }


    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");

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

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

        int[] readArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }
    }

} Main public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        String x = fs.next();
        char[] xx = x.toCharArray();

        ArrayList<Integer> summer = new ArrayList<>();

        for (int i = 0; i<xx.length;i++) {
            summer.add((int) xx[i]-48);
        }

        int sum =0;
        for (int i = 0; i<summer.size(); i++) {
            sum+=summer.get(i);
        }
        if (sum % 9 == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }




    } main {
        FastScanner fs = new FastScanner();
        String x = fs.next();
        char[] xx = x.toCharArray();

        ArrayList<Integer> summer = new ArrayList<>();

        for (int i = 0; i<xx.length;i++) {
            summer.add((int) xx[i]-48);
        }

        int sum =0;
        for (int i = 0; i<summer.size(); i++) {
            sum+=summer.get(i);
        }
        if (sum % 9 == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }




    } FastScanner fs = new FastScanner(); fs new FastScanner() String x = fs.next(); x fs.next() fs.next fs char[] xx = x.toCharArray(); xx x.toCharArray() x.toCharArray x ArrayList<Integer> summer = new ArrayList<>(); summer new ArrayList<>() for (int i = 0; i<xx.length;i++) {
            summer.add((int) xx[i]-48);
        } int i = 0; int i = 0; i 0 i<xx.length i xx.length xx xx.length i++ i++ i {
            summer.add((int) xx[i]-48);
        } {
            summer.add((int) xx[i]-48);
        } summer.add((int) xx[i]-48) summer.add summer (int) xx[i]-48 (int) xx[i] xx i 48 int sum =0; sum 0 for (int i = 0; i<summer.size(); i++) {
            sum+=summer.get(i);
        } int i = 0; int i = 0; i 0 i<summer.size() i summer.size() summer.size summer i++ i++ i {
            sum+=summer.get(i);
        } {
            sum+=summer.get(i);
        } sum+=summer.get(i) sum summer.get(i) summer.get summer i if (sum % 9 == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        } sum % 9 == 0 sum % 9 sum 9 0 {
            System.out.println("Yes");
        } System.out.println("Yes") System.out.println System.out System System.out "Yes" {
            System.out.println("No");
        } System.out.println("No") System.out.println System.out System System.out "No" String[] args args static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");

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

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

        int[] readArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }
    } FastScanner BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringTokenizer st=new StringTokenizer(""); st new StringTokenizer("") public String next() {
            while (!st.hasMoreElements())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        } next {
            while (!st.hasMoreElements())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        } while (!st.hasMoreElements())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                } !st.hasMoreElements() st.hasMoreElements() st.hasMoreElements st 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 int[] readArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        } readArray {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        } int[] a=new int[n]; a new int[n] n for (int i=0; i<n; i++) a[i]=nextInt(); int i=0; int i=0; i 0 i<n i n i++ i++ i a[i]=nextInt(); a[i]=nextInt() a[i] a i nextInt() nextInt return a; a int n n public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        String x = fs.next();
        char[] xx = x.toCharArray();

        ArrayList<Integer> summer = new ArrayList<>();

        for (int i = 0; i<xx.length;i++) {
            summer.add((int) xx[i]-48);
        }

        int sum =0;
        for (int i = 0; i<summer.size(); i++) {
            sum+=summer.get(i);
        }
        if (sum % 9 == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }




    }


    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");

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

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

        int[] readArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }
    }

} public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        String x = fs.next();
        char[] xx = x.toCharArray();

        ArrayList<Integer> summer = new ArrayList<>();

        for (int i = 0; i<xx.length;i++) {
            summer.add((int) xx[i]-48);
        }

        int sum =0;
        for (int i = 0; i<summer.size(); i++) {
            sum+=summer.get(i);
        }
        if (sum % 9 == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }




    }


    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");

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

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

        int[] readArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }
    }

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.util.Arrays;
import java.lang.Math;

public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        String x = fs.next();
        char[] xx = x.toCharArray();

        ArrayList<Integer> summer = new ArrayList<>();

        for (int i = 0; i<xx.length;i++) {
            summer.add((int) xx[i]-48);
        }

        int sum =0;
        for (int i = 0; i<summer.size(); i++) {
            sum+=summer.get(i);
        }
        if (sum % 9 == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }




    }


    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");

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

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

        int[] readArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }
    }

}

