import java.util.*;
import java.io.*;
import java.util.Arrays; 
import java.util.ArrayList; 
import java.util.Collections; 
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.StringTokenizer;
import java.math.BigInteger;

public class Main {

    public static void main(String[] args) {
        try (PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {
            Scanner in = new Scanner(System.in);  
            BigInteger n = in.nextBigInteger();  

            /*
            BigInteger sum = BigInteger.ZERO;
            while ((n.compareTo(new BigInteger("0"))) == 1) {
                BigInteger mod = n.mod(new BigInteger("10")); 
                sum = sum.add(mod);
                n = n.divide(new BigInteger("10"));
            }
            //out.println(sum);
            //out.println(sum.mod(new BigInteger("9")));

            if((sum.mod(new BigInteger("9"))).equals(new BigInteger("0"))) {
                out.println("Yes");
            } else {
                out.println("No");
            }*/

            if((n.mod(new BigInteger("9"))).equals(new BigInteger("0"))) {
                out.println("Yes");
            } else {
                out.println("No");
            }








        } finally {
            //out.close();
        }
        
           
    }
}




class FastScanner {
   private final BufferedReader br;
   private StringTokenizer st;
 
    FastScanner(InputStream InputStream) {
        br = new BufferedReader(new InputStreamReader(InputStream));
    }
    
    String next() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return st.nextToken();
    }
    
    int nextInt() {
        return Integer.parseInt(next());
    }
    
    long nextLong() {
        return Long.parseLong(next());
    }
    
    double nextDouble() {
        return Double.parseDouble(next());
    }


    
    ArrayList<Integer> nextIntList(int count) {
        ArrayList<Integer> array = new ArrayList<>();
        for (int n = 0; n < count; n++) {
            int number = nextInt();
            array.add(number);
        }
        return array;
    }
    
    int[] nextIntArray(int count) {
        int[] array = new int[count];
        for (int n = 0; n < count; n++) {
            array[n] = nextInt();
        }
        return array;
    }
} import java.util.*; util.* java import java.io.*; io.* java import java.util.Arrays; Arrays java.util import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.InputStream; InputStream java.io import java.util.StringTokenizer; StringTokenizer java.util import java.math.BigInteger; BigInteger java.math public class Main {

    public static void main(String[] args) {
        try (PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {
            Scanner in = new Scanner(System.in);  
            BigInteger n = in.nextBigInteger();  

            /*
            BigInteger sum = BigInteger.ZERO;
            while ((n.compareTo(new BigInteger("0"))) == 1) {
                BigInteger mod = n.mod(new BigInteger("10")); 
                sum = sum.add(mod);
                n = n.divide(new BigInteger("10"));
            }
            //out.println(sum);
            //out.println(sum.mod(new BigInteger("9")));

            if((sum.mod(new BigInteger("9"))).equals(new BigInteger("0"))) {
                out.println("Yes");
            } else {
                out.println("No");
            }*/

            if((n.mod(new BigInteger("9"))).equals(new BigInteger("0"))) {
                out.println("Yes");
            } else {
                out.println("No");
            }








        } finally {
            //out.close();
        }
        
           
    }
} Main public static void main(String[] args) {
        try (PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {
            Scanner in = new Scanner(System.in);  
            BigInteger n = in.nextBigInteger();  

            /*
            BigInteger sum = BigInteger.ZERO;
            while ((n.compareTo(new BigInteger("0"))) == 1) {
                BigInteger mod = n.mod(new BigInteger("10")); 
                sum = sum.add(mod);
                n = n.divide(new BigInteger("10"));
            }
            //out.println(sum);
            //out.println(sum.mod(new BigInteger("9")));

            if((sum.mod(new BigInteger("9"))).equals(new BigInteger("0"))) {
                out.println("Yes");
            } else {
                out.println("No");
            }*/

            if((n.mod(new BigInteger("9"))).equals(new BigInteger("0"))) {
                out.println("Yes");
            } else {
                out.println("No");
            }








        } finally {
            //out.close();
        }
        
           
    } main {
        try (PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {
            Scanner in = new Scanner(System.in);  
            BigInteger n = in.nextBigInteger();  

            /*
            BigInteger sum = BigInteger.ZERO;
            while ((n.compareTo(new BigInteger("0"))) == 1) {
                BigInteger mod = n.mod(new BigInteger("10")); 
                sum = sum.add(mod);
                n = n.divide(new BigInteger("10"));
            }
            //out.println(sum);
            //out.println(sum.mod(new BigInteger("9")));

            if((sum.mod(new BigInteger("9"))).equals(new BigInteger("0"))) {
                out.println("Yes");
            } else {
                out.println("No");
            }*/

            if((n.mod(new BigInteger("9"))).equals(new BigInteger("0"))) {
                out.println("Yes");
            } else {
                out.println("No");
            }








        } finally {
            //out.close();
        }
        
           
    } try (PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {
            Scanner in = new Scanner(System.in);  
            BigInteger n = in.nextBigInteger();  

            /*
            BigInteger sum = BigInteger.ZERO;
            while ((n.compareTo(new BigInteger("0"))) == 1) {
                BigInteger mod = n.mod(new BigInteger("10")); 
                sum = sum.add(mod);
                n = n.divide(new BigInteger("10"));
            }
            //out.println(sum);
            //out.println(sum.mod(new BigInteger("9")));

            if((sum.mod(new BigInteger("9"))).equals(new BigInteger("0"))) {
                out.println("Yes");
            } else {
                out.println("No");
            }*/

            if((n.mod(new BigInteger("9"))).equals(new BigInteger("0"))) {
                out.println("Yes");
            } else {
                out.println("No");
            }








        } finally {
            //out.close();
        } {
            //out.close();
        } {
            Scanner in = new Scanner(System.in);  
            BigInteger n = in.nextBigInteger();  

            /*
            BigInteger sum = BigInteger.ZERO;
            while ((n.compareTo(new BigInteger("0"))) == 1) {
                BigInteger mod = n.mod(new BigInteger("10")); 
                sum = sum.add(mod);
                n = n.divide(new BigInteger("10"));
            }
            //out.println(sum);
            //out.println(sum.mod(new BigInteger("9")));

            if((sum.mod(new BigInteger("9"))).equals(new BigInteger("0"))) {
                out.println("Yes");
            } else {
                out.println("No");
            }*/

            if((n.mod(new BigInteger("9"))).equals(new BigInteger("0"))) {
                out.println("Yes");
            } else {
                out.println("No");
            }








        } PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)) PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)) new PrintWriter(new BufferedOutputStream(System.out)) Scanner in = new Scanner(System.in); in new Scanner(System.in) BigInteger n = in.nextBigInteger(); n in.nextBigInteger() in.nextBigInteger in if((n.mod(new BigInteger("9"))).equals(new BigInteger("0"))) {
                out.println("Yes");
            } else {
                out.println("No");
            } (n.mod(new BigInteger("9"))).equals(new BigInteger("0")) (n.mod(new BigInteger("9"))).equals (n.mod(new BigInteger("9"))) n.mod n new BigInteger("9") new BigInteger("0") {
                out.println("Yes");
            } out.println("Yes") out.println out "Yes" {
                out.println("No");
            } out.println("No") out.println out "No" String[] args args class FastScanner {
   private final BufferedReader br;
   private StringTokenizer st;
 
    FastScanner(InputStream InputStream) {
        br = new BufferedReader(new InputStreamReader(InputStream));
    }
    
    String next() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return st.nextToken();
    }
    
    int nextInt() {
        return Integer.parseInt(next());
    }
    
    long nextLong() {
        return Long.parseLong(next());
    }
    
    double nextDouble() {
        return Double.parseDouble(next());
    }


    
    ArrayList<Integer> nextIntList(int count) {
        ArrayList<Integer> array = new ArrayList<>();
        for (int n = 0; n < count; n++) {
            int number = nextInt();
            array.add(number);
        }
        return array;
    }
    
    int[] nextIntArray(int count) {
        int[] array = new int[count];
        for (int n = 0; n < count; n++) {
            array[n] = nextInt();
        }
        return array;
    }
} FastScanner private final BufferedReader br; br private StringTokenizer st; st FastScanner(InputStream InputStream) {
        br = new BufferedReader(new InputStreamReader(InputStream));
    } FastScanner {
        br = new BufferedReader(new InputStreamReader(InputStream));
    } br = new BufferedReader(new InputStreamReader(InputStream)) br new BufferedReader(new InputStreamReader(InputStream)) InputStream InputStream InputStream String next() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return st.nextToken();
    } next {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return st.nextToken();
    } while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        } st == null || !st.hasMoreTokens() st == null st null !st.hasMoreTokens() st.hasMoreTokens() st.hasMoreTokens st {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        } try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            } catch (IOException e) {
                throw new RuntimeException(e);
            } IOException e {
                throw new RuntimeException(e);
            } throw new RuntimeException(e); new RuntimeException(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 ArrayList<Integer> nextIntList(int count) {
        ArrayList<Integer> array = new ArrayList<>();
        for (int n = 0; n < count; n++) {
            int number = nextInt();
            array.add(number);
        }
        return array;
    } nextIntList {
        ArrayList<Integer> array = new ArrayList<>();
        for (int n = 0; n < count; n++) {
            int number = nextInt();
            array.add(number);
        }
        return array;
    } ArrayList<Integer> array = new ArrayList<>(); array new ArrayList<>() for (int n = 0; n < count; n++) {
            int number = nextInt();
            array.add(number);
        } int n = 0; int n = 0; n 0 n < count n count n++ n++ n {
            int number = nextInt();
            array.add(number);
        } {
            int number = nextInt();
            array.add(number);
        } int number = nextInt(); number nextInt() nextInt array.add(number) array.add array number return array; array int count count int[] nextIntArray(int count) {
        int[] array = new int[count];
        for (int n = 0; n < count; n++) {
            array[n] = nextInt();
        }
        return array;
    } nextIntArray {
        int[] array = new int[count];
        for (int n = 0; n < count; n++) {
            array[n] = nextInt();
        }
        return array;
    } int[] array = new int[count]; array new int[count] count for (int n = 0; n < count; n++) {
            array[n] = nextInt();
        } int n = 0; int n = 0; n 0 n < count n count n++ n++ n {
            array[n] = nextInt();
        } {
            array[n] = nextInt();
        } array[n] = nextInt() array[n] array n nextInt() nextInt return array; array int count count public class Main {

    public static void main(String[] args) {
        try (PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {
            Scanner in = new Scanner(System.in);  
            BigInteger n = in.nextBigInteger();  

            /*
            BigInteger sum = BigInteger.ZERO;
            while ((n.compareTo(new BigInteger("0"))) == 1) {
                BigInteger mod = n.mod(new BigInteger("10")); 
                sum = sum.add(mod);
                n = n.divide(new BigInteger("10"));
            }
            //out.println(sum);
            //out.println(sum.mod(new BigInteger("9")));

            if((sum.mod(new BigInteger("9"))).equals(new BigInteger("0"))) {
                out.println("Yes");
            } else {
                out.println("No");
            }*/

            if((n.mod(new BigInteger("9"))).equals(new BigInteger("0"))) {
                out.println("Yes");
            } else {
                out.println("No");
            }








        } finally {
            //out.close();
        }
        
           
    }
} public class Main {

    public static void main(String[] args) {
        try (PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {
            Scanner in = new Scanner(System.in);  
            BigInteger n = in.nextBigInteger();  

            /*
            BigInteger sum = BigInteger.ZERO;
            while ((n.compareTo(new BigInteger("0"))) == 1) {
                BigInteger mod = n.mod(new BigInteger("10")); 
                sum = sum.add(mod);
                n = n.divide(new BigInteger("10"));
            }
            //out.println(sum);
            //out.println(sum.mod(new BigInteger("9")));

            if((sum.mod(new BigInteger("9"))).equals(new BigInteger("0"))) {
                out.println("Yes");
            } else {
                out.println("No");
            }*/

            if((n.mod(new BigInteger("9"))).equals(new BigInteger("0"))) {
                out.println("Yes");
            } else {
                out.println("No");
            }








        } finally {
            //out.close();
        }
        
           
    }
} Main
import java.util.*;
import java.io.*;
import java.util.Arrays; 
import java.util.ArrayList; 
import java.util.Collections; 
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.StringTokenizer;
import java.math.BigInteger;

public class Main {

    public static void main(String[] args) {
        try (PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {
            Scanner in = new Scanner(System.in);  
            BigInteger n = in.nextBigInteger();  

            /*
            BigInteger sum = BigInteger.ZERO;
            while ((n.compareTo(new BigInteger("0"))) == 1) {
                BigInteger mod = n.mod(new BigInteger("10")); 
                sum = sum.add(mod);
                n = n.divide(new BigInteger("10"));
            }
            //out.println(sum);
            //out.println(sum.mod(new BigInteger("9")));

            if((sum.mod(new BigInteger("9"))).equals(new BigInteger("0"))) {
                out.println("Yes");
            } else {
                out.println("No");
            }*/

            if((n.mod(new BigInteger("9"))).equals(new BigInteger("0"))) {
                out.println("Yes");
            } else {
                out.println("No");
            }








        } finally {
            //out.close();
        }
        
           
    }
}




class FastScanner {
   private final BufferedReader br;
   private StringTokenizer st;
 
    FastScanner(InputStream InputStream) {
        br = new BufferedReader(new InputStreamReader(InputStream));
    }
    
    String next() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return st.nextToken();
    }
    
    int nextInt() {
        return Integer.parseInt(next());
    }
    
    long nextLong() {
        return Long.parseLong(next());
    }
    
    double nextDouble() {
        return Double.parseDouble(next());
    }


    
    ArrayList<Integer> nextIntList(int count) {
        ArrayList<Integer> array = new ArrayList<>();
        for (int n = 0; n < count; n++) {
            int number = nextInt();
            array.add(number);
        }
        return array;
    }
    
    int[] nextIntArray(int count) {
        int[] array = new int[count];
        for (int n = 0; n < count; n++) {
            array[n] = nextInt();
        }
        return array;
    }
}
