// package Contest#176;
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        String str = br.readLine();
        int sum = 0;
        for(int i=0; i<str.length(); i++){
            sum += str.charAt(i)-'0';
        }

        if(sum % 9 == 0){
            out.println("Yes");
        }else{
            out.println("No");
        }
        out.close();
    }
} import java.util.*; util.* java import java.io.*; io.* java public class Main {
    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        String str = br.readLine();
        int sum = 0;
        for(int i=0; i<str.length(); i++){
            sum += str.charAt(i)-'0';
        }

        if(sum % 9 == 0){
            out.println("Yes");
        }else{
            out.println("No");
        }
        out.close();
    }
} Main public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        String str = br.readLine();
        int sum = 0;
        for(int i=0; i<str.length(); i++){
            sum += str.charAt(i)-'0';
        }

        if(sum % 9 == 0){
            out.println("Yes");
        }else{
            out.println("No");
        }
        out.close();
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        String str = br.readLine();
        int sum = 0;
        for(int i=0; i<str.length(); i++){
            sum += str.charAt(i)-'0';
        }

        if(sum % 9 == 0){
            out.println("Yes");
        }else{
            out.println("No");
        }
        out.close();
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) String str = br.readLine(); str br.readLine() br.readLine br int sum = 0; sum 0 for(int i=0; i<str.length(); i++){
            sum += str.charAt(i)-'0';
        } int i=0; int i=0; i 0 i<str.length() i str.length() str.length str i++ i++ i {
            sum += str.charAt(i)-'0';
        } {
            sum += str.charAt(i)-'0';
        } sum += str.charAt(i)-'0' sum str.charAt(i)-'0' str.charAt(i) str.charAt str i '0' if(sum % 9 == 0){
            out.println("Yes");
        }else{
            out.println("No");
        } sum % 9 == 0 sum % 9 sum 9 0 {
            out.println("Yes");
        } out.println("Yes") out.println out "Yes" {
            out.println("No");
        } out.println("No") out.println out "No" out.close() out.close out String[] args args public class Main {
    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        String str = br.readLine();
        int sum = 0;
        for(int i=0; i<str.length(); i++){
            sum += str.charAt(i)-'0';
        }

        if(sum % 9 == 0){
            out.println("Yes");
        }else{
            out.println("No");
        }
        out.close();
    }
} public class Main {
    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        String str = br.readLine();
        int sum = 0;
        for(int i=0; i<str.length(); i++){
            sum += str.charAt(i)-'0';
        }

        if(sum % 9 == 0){
            out.println("Yes");
        }else{
            out.println("No");
        }
        out.close();
    }
} Main
// package Contest#176;
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        String str = br.readLine();
        int sum = 0;
        for(int i=0; i<str.length(); i++){
            sum += str.charAt(i)-'0';
        }

        if(sum % 9 == 0){
            out.println("Yes");
        }else{
            out.println("No");
        }
        out.close();
    }
}