import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
			
			String s = sc.next();
			
			int len = s.length();
			int cnt = 0;
			char[] sChars = s.toCharArray();
			
			for(int i=0;i<len;i++) {
				cnt= cnt+Character.getNumericValue(sChars[i]);		
			}
			
			if(Math.floorMod(cnt,9)==0) {
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
				
			}
	}	
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
			
			String s = sc.next();
			
			int len = s.length();
			int cnt = 0;
			char[] sChars = s.toCharArray();
			
			for(int i=0;i<len;i++) {
				cnt= cnt+Character.getNumericValue(sChars[i]);		
			}
			
			if(Math.floorMod(cnt,9)==0) {
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
				
			}
	}	
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
			
			String s = sc.next();
			
			int len = s.length();
			int cnt = 0;
			char[] sChars = s.toCharArray();
			
			for(int i=0;i<len;i++) {
				cnt= cnt+Character.getNumericValue(sChars[i]);		
			}
			
			if(Math.floorMod(cnt,9)==0) {
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
				
			}
	} main {
		Scanner sc = new Scanner(System.in);
			
			String s = sc.next();
			
			int len = s.length();
			int cnt = 0;
			char[] sChars = s.toCharArray();
			
			for(int i=0;i<len;i++) {
				cnt= cnt+Character.getNumericValue(sChars[i]);		
			}
			
			if(Math.floorMod(cnt,9)==0) {
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
				
			}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc int len = s.length(); len s.length() s.length s int cnt = 0; cnt 0 char[] sChars = s.toCharArray(); sChars s.toCharArray() s.toCharArray s for(int i=0;i<len;i++) {
				cnt= cnt+Character.getNumericValue(sChars[i]);		
			} int i=0; int i=0; i 0 i<len i len i++ i++ i {
				cnt= cnt+Character.getNumericValue(sChars[i]);		
			} {
				cnt= cnt+Character.getNumericValue(sChars[i]);		
			} cnt= cnt+Character.getNumericValue(sChars[i]) cnt cnt+Character.getNumericValue(sChars[i]) cnt Character.getNumericValue(sChars[i]) Character.getNumericValue Character sChars[i] sChars i if(Math.floorMod(cnt,9)==0) {
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
				
			} Math.floorMod(cnt,9)==0 Math.floorMod(cnt,9) Math.floorMod Math cnt 9 0 {
				System.out.println("Yes");
			} System.out.println("Yes") System.out.println System.out System System.out "Yes" {
				System.out.println("No");
				
			} 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);
			
			String s = sc.next();
			
			int len = s.length();
			int cnt = 0;
			char[] sChars = s.toCharArray();
			
			for(int i=0;i<len;i++) {
				cnt= cnt+Character.getNumericValue(sChars[i]);		
			}
			
			if(Math.floorMod(cnt,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);
			
			String s = sc.next();
			
			int len = s.length();
			int cnt = 0;
			char[] sChars = s.toCharArray();
			
			for(int i=0;i<len;i++) {
				cnt= cnt+Character.getNumericValue(sChars[i]);		
			}
			
			if(Math.floorMod(cnt,9)==0) {
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
				
			}
	}	
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
			
			String s = sc.next();
			
			int len = s.length();
			int cnt = 0;
			char[] sChars = s.toCharArray();
			
			for(int i=0;i<len;i++) {
				cnt= cnt+Character.getNumericValue(sChars[i]);		
			}
			
			if(Math.floorMod(cnt,9)==0) {
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
				
			}
	}	
}