import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.nextLine();
		int answer = 0;
		String max;
		int w =0;
		while(w != n.length()){
			char c = n.charAt(w);
			int i = Character.getNumericValue(c);
			answer += i; 
			w++; 
		}
		if(answer % 9 == 0){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}
	}
} import java.util.Scanner; Scanner java.util import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.nextLine();
		int answer = 0;
		String max;
		int w =0;
		while(w != n.length()){
			char c = n.charAt(w);
			int i = Character.getNumericValue(c);
			answer += i; 
			w++; 
		}
		if(answer % 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 n = sc.nextLine();
		int answer = 0;
		String max;
		int w =0;
		while(w != n.length()){
			char c = n.charAt(w);
			int i = Character.getNumericValue(c);
			answer += i; 
			w++; 
		}
		if(answer % 9 == 0){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}
	} main {
		Scanner sc = new Scanner(System.in);
		String n = sc.nextLine();
		int answer = 0;
		String max;
		int w =0;
		while(w != n.length()){
			char c = n.charAt(w);
			int i = Character.getNumericValue(c);
			answer += i; 
			w++; 
		}
		if(answer % 9 == 0){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String n = sc.nextLine(); n sc.nextLine() sc.nextLine sc int answer = 0; answer 0 String max; max int w =0; w 0 while(w != n.length()){
			char c = n.charAt(w);
			int i = Character.getNumericValue(c);
			answer += i; 
			w++; 
		} w != n.length() w n.length() n.length n {
			char c = n.charAt(w);
			int i = Character.getNumericValue(c);
			answer += i; 
			w++; 
		} char c = n.charAt(w); c n.charAt(w) n.charAt n w int i = Character.getNumericValue(c); i Character.getNumericValue(c) Character.getNumericValue Character c answer += i answer i w++ w if(answer % 9 == 0){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		} answer % 9 == 0 answer % 9 answer 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 n = sc.nextLine();
		int answer = 0;
		String max;
		int w =0;
		while(w != n.length()){
			char c = n.charAt(w);
			int i = Character.getNumericValue(c);
			answer += i; 
			w++; 
		}
		if(answer % 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 n = sc.nextLine();
		int answer = 0;
		String max;
		int w =0;
		while(w != n.length()){
			char c = n.charAt(w);
			int i = Character.getNumericValue(c);
			answer += i; 
			w++; 
		}
		if(answer % 9 == 0){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}
	}
} Main
import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.nextLine();
		int answer = 0;
		String max;
		int w =0;
		while(w != n.length()){
			char c = n.charAt(w);
			int i = Character.getNumericValue(c);
			answer += i; 
			w++; 
		}
		if(answer % 9 == 0){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}
	}
}
