import java.util.*;
public class Main{
	
	
	private static Scanner sc=new Scanner(System.in);
	
	public static void main(String []args){
		
		String num=sc.nextLine();
		int reminder=0;
		for(int i=0;i<num.length();i++){
			reminder+=num.charAt(i)-'0';
			if(reminder>=9)
				reminder-=9;
		}
		if(reminder==0)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
	
} import java.util.*; util.* java public class Main{
	
	
	private static Scanner sc=new Scanner(System.in);
	
	public static void main(String []args){
		
		String num=sc.nextLine();
		int reminder=0;
		for(int i=0;i<num.length();i++){
			reminder+=num.charAt(i)-'0';
			if(reminder>=9)
				reminder-=9;
		}
		if(reminder==0)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
	
} Main private static Scanner sc=new Scanner(System.in); sc new Scanner(System.in) public static void main(String []args){
		
		String num=sc.nextLine();
		int reminder=0;
		for(int i=0;i<num.length();i++){
			reminder+=num.charAt(i)-'0';
			if(reminder>=9)
				reminder-=9;
		}
		if(reminder==0)
			System.out.println("Yes");
		else
			System.out.println("No");
	} main {
		
		String num=sc.nextLine();
		int reminder=0;
		for(int i=0;i<num.length();i++){
			reminder+=num.charAt(i)-'0';
			if(reminder>=9)
				reminder-=9;
		}
		if(reminder==0)
			System.out.println("Yes");
		else
			System.out.println("No");
	} String num=sc.nextLine(); num sc.nextLine() sc.nextLine sc int reminder=0; reminder 0 for(int i=0;i<num.length();i++){
			reminder+=num.charAt(i)-'0';
			if(reminder>=9)
				reminder-=9;
		} int i=0; int i=0; i 0 i<num.length() i num.length() num.length num i++ i++ i {
			reminder+=num.charAt(i)-'0';
			if(reminder>=9)
				reminder-=9;
		} {
			reminder+=num.charAt(i)-'0';
			if(reminder>=9)
				reminder-=9;
		} reminder+=num.charAt(i)-'0' reminder num.charAt(i)-'0' num.charAt(i) num.charAt num i '0' if(reminder>=9)
				reminder-=9; reminder>=9 reminder 9 reminder-=9 reminder 9 if(reminder==0)
			System.out.println("Yes");
		else
			System.out.println("No"); reminder==0 reminder 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{
	
	
	private static Scanner sc=new Scanner(System.in);
	
	public static void main(String []args){
		
		String num=sc.nextLine();
		int reminder=0;
		for(int i=0;i<num.length();i++){
			reminder+=num.charAt(i)-'0';
			if(reminder>=9)
				reminder-=9;
		}
		if(reminder==0)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
	
} public class Main{
	
	
	private static Scanner sc=new Scanner(System.in);
	
	public static void main(String []args){
		
		String num=sc.nextLine();
		int reminder=0;
		for(int i=0;i<num.length();i++){
			reminder+=num.charAt(i)-'0';
			if(reminder>=9)
				reminder-=9;
		}
		if(reminder==0)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
	
} Main
import java.util.*;
public class Main{
	
	
	private static Scanner sc=new Scanner(System.in);
	
	public static void main(String []args){
		
		String num=sc.nextLine();
		int reminder=0;
		for(int i=0;i<num.length();i++){
			reminder+=num.charAt(i)-'0';
			if(reminder>=9)
				reminder-=9;
		}
		if(reminder==0)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
	
}