import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		String[] num_str = str.split("");

		int result=0;
		int[] num_int = new int[num_str.length];

		for(int i=0; i < num_int.length; i++){
			num_int[i] = Integer.parseInt(num_str[i]);

			result += num_int[i]; 
		}
		sc.close();

		if(result % 9 == 0){
			System.out.println("Yes");
		}else{
		System.out.println("No");
		}
	}
} import java.util.*; util.* java public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		String[] num_str = str.split("");

		int result=0;
		int[] num_int = new int[num_str.length];

		for(int i=0; i < num_int.length; i++){
			num_int[i] = Integer.parseInt(num_str[i]);

			result += num_int[i]; 
		}
		sc.close();

		if(result % 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 str = sc.nextLine();
		String[] num_str = str.split("");

		int result=0;
		int[] num_int = new int[num_str.length];

		for(int i=0; i < num_int.length; i++){
			num_int[i] = Integer.parseInt(num_str[i]);

			result += num_int[i]; 
		}
		sc.close();

		if(result % 9 == 0){
			System.out.println("Yes");
		}else{
		System.out.println("No");
		}
	} main {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		String[] num_str = str.split("");

		int result=0;
		int[] num_int = new int[num_str.length];

		for(int i=0; i < num_int.length; i++){
			num_int[i] = Integer.parseInt(num_str[i]);

			result += num_int[i]; 
		}
		sc.close();

		if(result % 9 == 0){
			System.out.println("Yes");
		}else{
		System.out.println("No");
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String str = sc.nextLine(); str sc.nextLine() sc.nextLine sc String[] num_str = str.split(""); num_str str.split("") str.split str "" int result=0; result 0 int[] num_int = new int[num_str.length]; num_int new int[num_str.length] num_str.length num_str num_str.length for(int i=0; i < num_int.length; i++){
			num_int[i] = Integer.parseInt(num_str[i]);

			result += num_int[i]; 
		} int i=0; int i=0; i 0 i < num_int.length i num_int.length num_int num_int.length i++ i++ i {
			num_int[i] = Integer.parseInt(num_str[i]);

			result += num_int[i]; 
		} {
			num_int[i] = Integer.parseInt(num_str[i]);

			result += num_int[i]; 
		} num_int[i] = Integer.parseInt(num_str[i]) num_int[i] num_int i Integer.parseInt(num_str[i]) Integer.parseInt Integer num_str[i] num_str i result += num_int[i] result num_int[i] num_int i sc.close() sc.close sc if(result % 9 == 0){
			System.out.println("Yes");
		}else{
		System.out.println("No");
		} result % 9 == 0 result % 9 result 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 str = sc.nextLine();
		String[] num_str = str.split("");

		int result=0;
		int[] num_int = new int[num_str.length];

		for(int i=0; i < num_int.length; i++){
			num_int[i] = Integer.parseInt(num_str[i]);

			result += num_int[i]; 
		}
		sc.close();

		if(result % 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 str = sc.nextLine();
		String[] num_str = str.split("");

		int result=0;
		int[] num_int = new int[num_str.length];

		for(int i=0; i < num_int.length; i++){
			num_int[i] = Integer.parseInt(num_str[i]);

			result += num_int[i]; 
		}
		sc.close();

		if(result % 9 == 0){
			System.out.println("Yes");
		}else{
		System.out.println("No");
		}
	}
} Main
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		String[] num_str = str.split("");

		int result=0;
		int[] num_int = new int[num_str.length];

		for(int i=0; i < num_int.length; i++){
			num_int[i] = Integer.parseInt(num_str[i]);

			result += num_int[i]; 
		}
		sc.close();

		if(result % 9 == 0){
			System.out.println("Yes");
		}else{
		System.out.println("No");
		}
	}
}
