
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner ob=new Scanner(System.in);
		char c[]=ob.next().toCharArray();
		int sum=0;
		for(int i=0;i<c.length;i++){
		sum=sum+Character.getNumericValue(c[i]);
		}
		if(sum%9==0){System.out.println("Yes");}
		else{System.out.println("No");}
	}
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner ob=new Scanner(System.in);
		char c[]=ob.next().toCharArray();
		int sum=0;
		for(int i=0;i<c.length;i++){
		sum=sum+Character.getNumericValue(c[i]);
		}
		if(sum%9==0){System.out.println("Yes");}
		else{System.out.println("No");}
	}
} Main public static void main(String[] args) {
		Scanner ob=new Scanner(System.in);
		char c[]=ob.next().toCharArray();
		int sum=0;
		for(int i=0;i<c.length;i++){
		sum=sum+Character.getNumericValue(c[i]);
		}
		if(sum%9==0){System.out.println("Yes");}
		else{System.out.println("No");}
	} main {
		Scanner ob=new Scanner(System.in);
		char c[]=ob.next().toCharArray();
		int sum=0;
		for(int i=0;i<c.length;i++){
		sum=sum+Character.getNumericValue(c[i]);
		}
		if(sum%9==0){System.out.println("Yes");}
		else{System.out.println("No");}
	} Scanner ob=new Scanner(System.in); ob new Scanner(System.in) char c[]=ob.next().toCharArray(); c ob.next().toCharArray() ob.next().toCharArray ob.next() ob.next ob int sum=0; sum 0 for(int i=0;i<c.length;i++){
		sum=sum+Character.getNumericValue(c[i]);
		} int i=0; int i=0; i 0 i<c.length i c.length c c.length i++ i++ i {
		sum=sum+Character.getNumericValue(c[i]);
		} {
		sum=sum+Character.getNumericValue(c[i]);
		} sum=sum+Character.getNumericValue(c[i]) sum sum+Character.getNumericValue(c[i]) sum Character.getNumericValue(c[i]) Character.getNumericValue Character c[i] c i if(sum%9==0){System.out.println("Yes");}
		else{System.out.println("No");} sum%9==0 sum%9 sum 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 ob=new Scanner(System.in);
		char c[]=ob.next().toCharArray();
		int sum=0;
		for(int i=0;i<c.length;i++){
		sum=sum+Character.getNumericValue(c[i]);
		}
		if(sum%9==0){System.out.println("Yes");}
		else{System.out.println("No");}
	}
} public class Main {

	public static void main(String[] args) {
		Scanner ob=new Scanner(System.in);
		char c[]=ob.next().toCharArray();
		int sum=0;
		for(int i=0;i<c.length;i++){
		sum=sum+Character.getNumericValue(c[i]);
		}
		if(sum%9==0){System.out.println("Yes");}
		else{System.out.println("No");}
	}
} Main

import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner ob=new Scanner(System.in);
		char c[]=ob.next().toCharArray();
		int sum=0;
		for(int i=0;i<c.length;i++){
		sum=sum+Character.getNumericValue(c[i]);
		}
		if(sum%9==0){System.out.println("Yes");}
		else{System.out.println("No");}
	}
}
