import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
            	
      	String kari = sc.next();
      	int num[] = new int[kari.length()];
      	int rt = 0;
      
      	for(int i = 0; i < kari.length(); i++) {
          num[i] = Integer.parseInt(kari.substring(i, i + 1));			
        }
            
      	for(int number : num) {
        	rt += number;
        }
      
      	if(rt % 9 == 0) {
      		System.out.println("Yes");
        } else {
      		System.out.println("No");
        }
    }
} import java.util.Scanner; Scanner java.util class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
            	
      	String kari = sc.next();
      	int num[] = new int[kari.length()];
      	int rt = 0;
      
      	for(int i = 0; i < kari.length(); i++) {
          num[i] = Integer.parseInt(kari.substring(i, i + 1));			
        }
            
      	for(int number : num) {
        	rt += number;
        }
      
      	if(rt % 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 kari = sc.next();
      	int num[] = new int[kari.length()];
      	int rt = 0;
      
      	for(int i = 0; i < kari.length(); i++) {
          num[i] = Integer.parseInt(kari.substring(i, i + 1));			
        }
            
      	for(int number : num) {
        	rt += number;
        }
      
      	if(rt % 9 == 0) {
      		System.out.println("Yes");
        } else {
      		System.out.println("No");
        }
    } main {
		Scanner sc = new Scanner(System.in);
            	
      	String kari = sc.next();
      	int num[] = new int[kari.length()];
      	int rt = 0;
      
      	for(int i = 0; i < kari.length(); i++) {
          num[i] = Integer.parseInt(kari.substring(i, i + 1));			
        }
            
      	for(int number : num) {
        	rt += number;
        }
      
      	if(rt % 9 == 0) {
      		System.out.println("Yes");
        } else {
      		System.out.println("No");
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String kari = sc.next(); kari sc.next() sc.next sc int num[] = new int[kari.length()]; num new int[kari.length()] kari.length() kari.length kari int rt = 0; rt 0 for(int i = 0; i < kari.length(); i++) {
          num[i] = Integer.parseInt(kari.substring(i, i + 1));			
        } int i = 0; int i = 0; i 0 i < kari.length() i kari.length() kari.length kari i++ i++ i {
          num[i] = Integer.parseInt(kari.substring(i, i + 1));			
        } {
          num[i] = Integer.parseInt(kari.substring(i, i + 1));			
        } num[i] = Integer.parseInt(kari.substring(i, i + 1)) num[i] num i Integer.parseInt(kari.substring(i, i + 1)) Integer.parseInt Integer kari.substring(i, i + 1) kari.substring kari i i + 1 i 1 for(int number : num) {
        	rt += number;
        } int number num {
        	rt += number;
        } {
        	rt += number;
        } rt += number rt number if(rt % 9 == 0) {
      		System.out.println("Yes");
        } else {
      		System.out.println("No");
        } rt % 9 == 0 rt % 9 rt 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
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
            	
      	String kari = sc.next();
      	int num[] = new int[kari.length()];
      	int rt = 0;
      
      	for(int i = 0; i < kari.length(); i++) {
          num[i] = Integer.parseInt(kari.substring(i, i + 1));			
        }
            
      	for(int number : num) {
        	rt += number;
        }
      
      	if(rt % 9 == 0) {
      		System.out.println("Yes");
        } else {
      		System.out.println("No");
        }
    }
}