import java.util.*;

public class Main {
public static void main(String[] args) {

			Scanner keyboard = new Scanner(System.in);

			 String S = keyboard.next();
			 long sum = 0;
			 String ans = "No";
			 		
			for (int s=0; s<S.length(); s++) {
				sum += (long)S.charAt(s)-48;
			}			
		
			if(sum%9 == 0) {
				ans = "Yes"; 
			}
		
		System.out.println(ans);
		keyboard.close();	
	}
} import java.util.*; util.* java public class Main {
public static void main(String[] args) {

			Scanner keyboard = new Scanner(System.in);

			 String S = keyboard.next();
			 long sum = 0;
			 String ans = "No";
			 		
			for (int s=0; s<S.length(); s++) {
				sum += (long)S.charAt(s)-48;
			}			
		
			if(sum%9 == 0) {
				ans = "Yes"; 
			}
		
		System.out.println(ans);
		keyboard.close();	
	}
} Main public static void main(String[] args) {

			Scanner keyboard = new Scanner(System.in);

			 String S = keyboard.next();
			 long sum = 0;
			 String ans = "No";
			 		
			for (int s=0; s<S.length(); s++) {
				sum += (long)S.charAt(s)-48;
			}			
		
			if(sum%9 == 0) {
				ans = "Yes"; 
			}
		
		System.out.println(ans);
		keyboard.close();	
	} main {

			Scanner keyboard = new Scanner(System.in);

			 String S = keyboard.next();
			 long sum = 0;
			 String ans = "No";
			 		
			for (int s=0; s<S.length(); s++) {
				sum += (long)S.charAt(s)-48;
			}			
		
			if(sum%9 == 0) {
				ans = "Yes"; 
			}
		
		System.out.println(ans);
		keyboard.close();	
	} Scanner keyboard = new Scanner(System.in); keyboard new Scanner(System.in) String S = keyboard.next(); S keyboard.next() keyboard.next keyboard long sum = 0; sum 0 String ans = "No"; ans "No" for (int s=0; s<S.length(); s++) {
				sum += (long)S.charAt(s)-48;
			} int s=0; int s=0; s 0 s<S.length() s S.length() S.length S s++ s++ s {
				sum += (long)S.charAt(s)-48;
			} {
				sum += (long)S.charAt(s)-48;
			} sum += (long)S.charAt(s)-48 sum (long)S.charAt(s)-48 (long)S.charAt(s) S.charAt S s 48 if(sum%9 == 0) {
				ans = "Yes"; 
			} sum%9 == 0 sum%9 sum 9 0 {
				ans = "Yes"; 
			} ans = "Yes" ans "Yes" System.out.println(ans) System.out.println System.out System System.out ans keyboard.close() keyboard.close keyboard String[] args args public class Main {
public static void main(String[] args) {

			Scanner keyboard = new Scanner(System.in);

			 String S = keyboard.next();
			 long sum = 0;
			 String ans = "No";
			 		
			for (int s=0; s<S.length(); s++) {
				sum += (long)S.charAt(s)-48;
			}			
		
			if(sum%9 == 0) {
				ans = "Yes"; 
			}
		
		System.out.println(ans);
		keyboard.close();	
	}
} public class Main {
public static void main(String[] args) {

			Scanner keyboard = new Scanner(System.in);

			 String S = keyboard.next();
			 long sum = 0;
			 String ans = "No";
			 		
			for (int s=0; s<S.length(); s++) {
				sum += (long)S.charAt(s)-48;
			}			
		
			if(sum%9 == 0) {
				ans = "Yes"; 
			}
		
		System.out.println(ans);
		keyboard.close();	
	}
} Main
import java.util.*;

public class Main {
public static void main(String[] args) {

			Scanner keyboard = new Scanner(System.in);

			 String S = keyboard.next();
			 long sum = 0;
			 String ans = "No";
			 		
			for (int s=0; s<S.length(); s++) {
				sum += (long)S.charAt(s)-48;
			}			
		
			if(sum%9 == 0) {
				ans = "Yes"; 
			}
		
		System.out.println(ans);
		keyboard.close();	
	}
}
