import java.util.*;

public class Main{
	public static void main(String arg[]){
		Scanner sc= new Scanner(System.in);
		String n = sc.next();
		long sum=0;
		for(int i=0;i<n.length();i++){
			sum=sum+Integer.parseInt(String.valueOf(n.charAt(i)));
		}
		
		if(sum%9==0)
			System.out.println("Yes");
		else 
			System.out.println("No");
	}
} import java.util.*; util.* java public class Main{
	public static void main(String arg[]){
		Scanner sc= new Scanner(System.in);
		String n = sc.next();
		long sum=0;
		for(int i=0;i<n.length();i++){
			sum=sum+Integer.parseInt(String.valueOf(n.charAt(i)));
		}
		
		if(sum%9==0)
			System.out.println("Yes");
		else 
			System.out.println("No");
	}
} Main public static void main(String arg[]){
		Scanner sc= new Scanner(System.in);
		String n = sc.next();
		long sum=0;
		for(int i=0;i<n.length();i++){
			sum=sum+Integer.parseInt(String.valueOf(n.charAt(i)));
		}
		
		if(sum%9==0)
			System.out.println("Yes");
		else 
			System.out.println("No");
	} main {
		Scanner sc= new Scanner(System.in);
		String n = sc.next();
		long sum=0;
		for(int i=0;i<n.length();i++){
			sum=sum+Integer.parseInt(String.valueOf(n.charAt(i)));
		}
		
		if(sum%9==0)
			System.out.println("Yes");
		else 
			System.out.println("No");
	} Scanner sc= new Scanner(System.in); sc new Scanner(System.in) String n = sc.next(); n sc.next() sc.next sc long sum=0; sum 0 for(int i=0;i<n.length();i++){
			sum=sum+Integer.parseInt(String.valueOf(n.charAt(i)));
		} int i=0; int i=0; i 0 i<n.length() i n.length() n.length n i++ i++ i {
			sum=sum+Integer.parseInt(String.valueOf(n.charAt(i)));
		} {
			sum=sum+Integer.parseInt(String.valueOf(n.charAt(i)));
		} sum=sum+Integer.parseInt(String.valueOf(n.charAt(i))) sum sum+Integer.parseInt(String.valueOf(n.charAt(i))) sum Integer.parseInt(String.valueOf(n.charAt(i))) Integer.parseInt Integer String.valueOf(n.charAt(i)) String.valueOf String n.charAt(i) n.charAt n 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 System.out System System.out "Yes" System.out.println("No") System.out.println System.out System System.out "No" String arg[] arg public class Main{
	public static void main(String arg[]){
		Scanner sc= new Scanner(System.in);
		String n = sc.next();
		long sum=0;
		for(int i=0;i<n.length();i++){
			sum=sum+Integer.parseInt(String.valueOf(n.charAt(i)));
		}
		
		if(sum%9==0)
			System.out.println("Yes");
		else 
			System.out.println("No");
	}
} public class Main{
	public static void main(String arg[]){
		Scanner sc= new Scanner(System.in);
		String n = sc.next();
		long sum=0;
		for(int i=0;i<n.length();i++){
			sum=sum+Integer.parseInt(String.valueOf(n.charAt(i)));
		}
		
		if(sum%9==0)
			System.out.println("Yes");
		else 
			System.out.println("No");
	}
} Main
import java.util.*;

public class Main{
	public static void main(String arg[]){
		Scanner sc= new Scanner(System.in);
		String n = sc.next();
		long sum=0;
		for(int i=0;i<n.length();i++){
			sum=sum+Integer.parseInt(String.valueOf(n.charAt(i)));
		}
		
		if(sum%9==0)
			System.out.println("Yes");
		else 
			System.out.println("No");
	}
}