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

	static Scanner inp= new Scanner(System.in);
	static PrintWriter out= new PrintWriter(System.out);
	public static void main(String args[]) {		    	
	   	Main g=new Main();
	   	g.main();
	   	out.close();
	}

	
	
	//Main
	void main() {
		
		String s=inp.next();
		int n=s.length();
		int gg=0;
		for(int i=0;i<n;i++) {
			gg+=(s.charAt(i)-'0');
		}
		System.out.println(gg%9==0?"Yes":"No");
		
	}
    
    
		
} import java.util.*; util.* java import java.io.*; io.* java public class Main {

	static Scanner inp= new Scanner(System.in);
	static PrintWriter out= new PrintWriter(System.out);
	public static void main(String args[]) {		    	
	   	Main g=new Main();
	   	g.main();
	   	out.close();
	}

	
	
	//Main
	void main() {
		
		String s=inp.next();
		int n=s.length();
		int gg=0;
		for(int i=0;i<n;i++) {
			gg+=(s.charAt(i)-'0');
		}
		System.out.println(gg%9==0?"Yes":"No");
		
	}
    
    
		
} Main static Scanner inp= new Scanner(System.in); inp new Scanner(System.in) static PrintWriter out= new PrintWriter(System.out); out new PrintWriter(System.out) public static void main(String args[]) {		    	
	   	Main g=new Main();
	   	g.main();
	   	out.close();
	} main {		    	
	   	Main g=new Main();
	   	g.main();
	   	out.close();
	} Main g=new Main(); g new Main() g.main() g.main g out.close() out.close out String args[] args //Main
	void main() {
		
		String s=inp.next();
		int n=s.length();
		int gg=0;
		for(int i=0;i<n;i++) {
			gg+=(s.charAt(i)-'0');
		}
		System.out.println(gg%9==0?"Yes":"No");
		
	} main {
		
		String s=inp.next();
		int n=s.length();
		int gg=0;
		for(int i=0;i<n;i++) {
			gg+=(s.charAt(i)-'0');
		}
		System.out.println(gg%9==0?"Yes":"No");
		
	} String s=inp.next(); s inp.next() inp.next inp int n=s.length(); n s.length() s.length s int gg=0; gg 0 for(int i=0;i<n;i++) {
			gg+=(s.charAt(i)-'0');
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			gg+=(s.charAt(i)-'0');
		} {
			gg+=(s.charAt(i)-'0');
		} gg+=(s.charAt(i)-'0') gg (s.charAt(i)-'0') s.charAt(i) s.charAt s i '0' System.out.println(gg%9==0?"Yes":"No") System.out.println System.out System System.out gg%9==0?"Yes":"No" gg%9==0 gg%9 gg 9 0 "Yes" "No" public class Main {

	static Scanner inp= new Scanner(System.in);
	static PrintWriter out= new PrintWriter(System.out);
	public static void main(String args[]) {		    	
	   	Main g=new Main();
	   	g.main();
	   	out.close();
	}

	
	
	//Main
	void main() {
		
		String s=inp.next();
		int n=s.length();
		int gg=0;
		for(int i=0;i<n;i++) {
			gg+=(s.charAt(i)-'0');
		}
		System.out.println(gg%9==0?"Yes":"No");
		
	}
    
    
		
} public class Main {

	static Scanner inp= new Scanner(System.in);
	static PrintWriter out= new PrintWriter(System.out);
	public static void main(String args[]) {		    	
	   	Main g=new Main();
	   	g.main();
	   	out.close();
	}

	
	
	//Main
	void main() {
		
		String s=inp.next();
		int n=s.length();
		int gg=0;
		for(int i=0;i<n;i++) {
			gg+=(s.charAt(i)-'0');
		}
		System.out.println(gg%9==0?"Yes":"No");
		
	}
    
    
		
} Main
import java.util.*;
import java.io.*;
public class Main {

	static Scanner inp= new Scanner(System.in);
	static PrintWriter out= new PrintWriter(System.out);
	public static void main(String args[]) {		    	
	   	Main g=new Main();
	   	g.main();
	   	out.close();
	}

	
	
	//Main
	void main() {
		
		String s=inp.next();
		int n=s.length();
		int gg=0;
		for(int i=0;i<n;i++) {
			gg+=(s.charAt(i)-'0');
		}
		System.out.println(gg%9==0?"Yes":"No");
		
	}
    
    
		
}
