import java.util.*;

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

		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		int sum = 0;
		
		for(char c : N.toCharArray()) {

			sum += Character.getNumericValue(c);
          	
			if(sum>=9){
				sum %= 9;
			}
		}
      
       if(sum==0){
			System.out.println("Yes");
       }else{
		System.out.println("No");
	   }
		
		return;
	}

} import java.util.*; util.* java public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		int sum = 0;
		
		for(char c : N.toCharArray()) {

			sum += Character.getNumericValue(c);
          	
			if(sum>=9){
				sum %= 9;
			}
		}
      
       if(sum==0){
			System.out.println("Yes");
       }else{
		System.out.println("No");
	   }
		
		return;
	}

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

		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		int sum = 0;
		
		for(char c : N.toCharArray()) {

			sum += Character.getNumericValue(c);
          	
			if(sum>=9){
				sum %= 9;
			}
		}
      
       if(sum==0){
			System.out.println("Yes");
       }else{
		System.out.println("No");
	   }
		
		return;
	} main {

		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		int sum = 0;
		
		for(char c : N.toCharArray()) {

			sum += Character.getNumericValue(c);
          	
			if(sum>=9){
				sum %= 9;
			}
		}
      
       if(sum==0){
			System.out.println("Yes");
       }else{
		System.out.println("No");
	   }
		
		return;
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String N = sc.next(); N sc.next() sc.next sc int sum = 0; sum 0 for(char c : N.toCharArray()) {

			sum += Character.getNumericValue(c);
          	
			if(sum>=9){
				sum %= 9;
			}
		} char c N.toCharArray() N.toCharArray N {

			sum += Character.getNumericValue(c);
          	
			if(sum>=9){
				sum %= 9;
			}
		} {

			sum += Character.getNumericValue(c);
          	
			if(sum>=9){
				sum %= 9;
			}
		} sum += Character.getNumericValue(c) sum Character.getNumericValue(c) Character.getNumericValue Character c if(sum>=9){
				sum %= 9;
			} sum>=9 sum 9 {
				sum %= 9;
			} sum %= 9 sum 9 if(sum==0){
			System.out.println("Yes");
       }else{
		System.out.println("No");
	   } sum==0 sum 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" return; String[] args args public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		int sum = 0;
		
		for(char c : N.toCharArray()) {

			sum += Character.getNumericValue(c);
          	
			if(sum>=9){
				sum %= 9;
			}
		}
      
       if(sum==0){
			System.out.println("Yes");
       }else{
		System.out.println("No");
	   }
		
		return;
	}

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

		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		int sum = 0;
		
		for(char c : N.toCharArray()) {

			sum += Character.getNumericValue(c);
          	
			if(sum>=9){
				sum %= 9;
			}
		}
      
       if(sum==0){
			System.out.println("Yes");
       }else{
		System.out.println("No");
	   }
		
		return;
	}

} Main
import java.util.*;

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

		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		int sum = 0;
		
		for(char c : N.toCharArray()) {

			sum += Character.getNumericValue(c);
          	
			if(sum>=9){
				sum %= 9;
			}
		}
      
       if(sum==0){
			System.out.println("Yes");
       }else{
		System.out.println("No");
	   }
		
		return;
	}

}
