import java.io.*;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=1;//sc.nextInt();
		while(t-->0) {
			String n=sc.next();
			long val=0;
			for(int i=0;i<n.length();i++) {
				val+=(n.charAt(i)-'0');
			}
			if(val%9==0) System.out.println("Yes");
			else System.out.println("No");
		}

	}

}
/*class Reader{
	BufferedReader reader;
	Reader(){
		reader=new BufferedReader(new InputStreamReader(System.in));
	}
	int nextInt() throws IOException{
		String in=reader.readLine().trim();
		return Integer.parseInt(in);
	}
	long nextLong() throws IOException{
		String in=reader.readLine().trim();
		return Long.parseLong(in);
	}
	String next() throws IOException{
		return reader.readLine().trim();
	}
	String[] stringArray() throws IOException{
		return reader.readLine().trim().split("\\s+");
	}
	int[] intArray() throws IOException{
		String[] inp=this.stringArray();
		int[] arr=new int[inp.length];
		int i=0;
		for(String s:inp) {
			arr[i++]=Integer.parseInt(s);
		}
		return arr;
	}
}*/

 import java.io.*; io.* java import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=1;//sc.nextInt();
		while(t-->0) {
			String n=sc.next();
			long val=0;
			for(int i=0;i<n.length();i++) {
				val+=(n.charAt(i)-'0');
			}
			if(val%9==0) System.out.println("Yes");
			else System.out.println("No");
		}

	}

} Main public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=1;//sc.nextInt();
		while(t-->0) {
			String n=sc.next();
			long val=0;
			for(int i=0;i<n.length();i++) {
				val+=(n.charAt(i)-'0');
			}
			if(val%9==0) System.out.println("Yes");
			else System.out.println("No");
		}

	} main {
		Scanner sc=new Scanner(System.in);
		int t=1;//sc.nextInt();
		while(t-->0) {
			String n=sc.next();
			long val=0;
			for(int i=0;i<n.length();i++) {
				val+=(n.charAt(i)-'0');
			}
			if(val%9==0) System.out.println("Yes");
			else System.out.println("No");
		}

	} Scanner sc=new Scanner(System.in); sc new Scanner(System.in) int t=1; t 1 while(t-->0) {
			String n=sc.next();
			long val=0;
			for(int i=0;i<n.length();i++) {
				val+=(n.charAt(i)-'0');
			}
			if(val%9==0) System.out.println("Yes");
			else System.out.println("No");
		} t-->0 t-- t 0 {
			String n=sc.next();
			long val=0;
			for(int i=0;i<n.length();i++) {
				val+=(n.charAt(i)-'0');
			}
			if(val%9==0) System.out.println("Yes");
			else System.out.println("No");
		} String n=sc.next(); n sc.next() sc.next sc long val=0; val 0 for(int i=0;i<n.length();i++) {
				val+=(n.charAt(i)-'0');
			} int i=0; int i=0; i 0 i<n.length() i n.length() n.length n i++ i++ i {
				val+=(n.charAt(i)-'0');
			} {
				val+=(n.charAt(i)-'0');
			} val+=(n.charAt(i)-'0') val (n.charAt(i)-'0') n.charAt(i) n.charAt n i '0' if(val%9==0) System.out.println("Yes");
			else System.out.println("No"); val%9==0 val%9 val 9 0 System.out.println("Yes") System.out.println System.out System System.out "Yes" System.out.println("No") System.out.println System.out System System.out "No" String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=1;//sc.nextInt();
		while(t-->0) {
			String n=sc.next();
			long val=0;
			for(int i=0;i<n.length();i++) {
				val+=(n.charAt(i)-'0');
			}
			if(val%9==0) System.out.println("Yes");
			else System.out.println("No");
		}

	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=1;//sc.nextInt();
		while(t-->0) {
			String n=sc.next();
			long val=0;
			for(int i=0;i<n.length();i++) {
				val+=(n.charAt(i)-'0');
			}
			if(val%9==0) System.out.println("Yes");
			else System.out.println("No");
		}

	}

} Main
import java.io.*;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=1;//sc.nextInt();
		while(t-->0) {
			String n=sc.next();
			long val=0;
			for(int i=0;i<n.length();i++) {
				val+=(n.charAt(i)-'0');
			}
			if(val%9==0) System.out.println("Yes");
			else System.out.println("No");
		}

	}

}
/*class Reader{
	BufferedReader reader;
	Reader(){
		reader=new BufferedReader(new InputStreamReader(System.in));
	}
	int nextInt() throws IOException{
		String in=reader.readLine().trim();
		return Integer.parseInt(in);
	}
	long nextLong() throws IOException{
		String in=reader.readLine().trim();
		return Long.parseLong(in);
	}
	String next() throws IOException{
		return reader.readLine().trim();
	}
	String[] stringArray() throws IOException{
		return reader.readLine().trim().split("\\s+");
	}
	int[] intArray() throws IOException{
		String[] inp=this.stringArray();
		int[] arr=new int[inp.length];
		int i=0;
		for(String s:inp) {
			arr[i++]=Integer.parseInt(s);
		}
		return arr;
	}
}*/


