import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		String N = stdIn.next();
		if(N.length() < 8){
			long A = new Long(N);
			if(A % 9 == 0){
				System.out.println("Yes");
			}
			else{
				System.out.println("No");
			}
		}
		else{
			int sum = 0;
			int a = 0;
			for(int i = 0; i < N.length(); i++){
				a = N.charAt(i);
				a = a - 48;
				sum = sum + a;
			}
			if(sum % 9 == 0){
				System.out.println("Yes");
			}
			else{
				System.out.println("No");
			}


		}
		stdIn.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		String N = stdIn.next();
		if(N.length() < 8){
			long A = new Long(N);
			if(A % 9 == 0){
				System.out.println("Yes");
			}
			else{
				System.out.println("No");
			}
		}
		else{
			int sum = 0;
			int a = 0;
			for(int i = 0; i < N.length(); i++){
				a = N.charAt(i);
				a = a - 48;
				sum = sum + a;
			}
			if(sum % 9 == 0){
				System.out.println("Yes");
			}
			else{
				System.out.println("No");
			}


		}
		stdIn.close();
	}
} Main public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		String N = stdIn.next();
		if(N.length() < 8){
			long A = new Long(N);
			if(A % 9 == 0){
				System.out.println("Yes");
			}
			else{
				System.out.println("No");
			}
		}
		else{
			int sum = 0;
			int a = 0;
			for(int i = 0; i < N.length(); i++){
				a = N.charAt(i);
				a = a - 48;
				sum = sum + a;
			}
			if(sum % 9 == 0){
				System.out.println("Yes");
			}
			else{
				System.out.println("No");
			}


		}
		stdIn.close();
	} main {
		Scanner stdIn = new Scanner(System.in);
		String N = stdIn.next();
		if(N.length() < 8){
			long A = new Long(N);
			if(A % 9 == 0){
				System.out.println("Yes");
			}
			else{
				System.out.println("No");
			}
		}
		else{
			int sum = 0;
			int a = 0;
			for(int i = 0; i < N.length(); i++){
				a = N.charAt(i);
				a = a - 48;
				sum = sum + a;
			}
			if(sum % 9 == 0){
				System.out.println("Yes");
			}
			else{
				System.out.println("No");
			}


		}
		stdIn.close();
	} Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) String N = stdIn.next(); N stdIn.next() stdIn.next stdIn if(N.length() < 8){
			long A = new Long(N);
			if(A % 9 == 0){
				System.out.println("Yes");
			}
			else{
				System.out.println("No");
			}
		}
		else{
			int sum = 0;
			int a = 0;
			for(int i = 0; i < N.length(); i++){
				a = N.charAt(i);
				a = a - 48;
				sum = sum + a;
			}
			if(sum % 9 == 0){
				System.out.println("Yes");
			}
			else{
				System.out.println("No");
			}


		} N.length() < 8 N.length() N.length N 8 {
			long A = new Long(N);
			if(A % 9 == 0){
				System.out.println("Yes");
			}
			else{
				System.out.println("No");
			}
		} long A = new Long(N); A new Long(N) if(A % 9 == 0){
				System.out.println("Yes");
			}
			else{
				System.out.println("No");
			} A % 9 == 0 A % 9 A 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" {
			int sum = 0;
			int a = 0;
			for(int i = 0; i < N.length(); i++){
				a = N.charAt(i);
				a = a - 48;
				sum = sum + a;
			}
			if(sum % 9 == 0){
				System.out.println("Yes");
			}
			else{
				System.out.println("No");
			}


		} int sum = 0; sum 0 int a = 0; a 0 for(int i = 0; i < N.length(); i++){
				a = N.charAt(i);
				a = a - 48;
				sum = sum + a;
			} int i = 0; int i = 0; i 0 i < N.length() i N.length() N.length N i++ i++ i {
				a = N.charAt(i);
				a = a - 48;
				sum = sum + a;
			} {
				a = N.charAt(i);
				a = a - 48;
				sum = sum + a;
			} a = N.charAt(i) a N.charAt(i) N.charAt N i a = a - 48 a a - 48 a 48 sum = sum + a sum sum + a sum a 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" stdIn.close() stdIn.close stdIn String[] args args public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		String N = stdIn.next();
		if(N.length() < 8){
			long A = new Long(N);
			if(A % 9 == 0){
				System.out.println("Yes");
			}
			else{
				System.out.println("No");
			}
		}
		else{
			int sum = 0;
			int a = 0;
			for(int i = 0; i < N.length(); i++){
				a = N.charAt(i);
				a = a - 48;
				sum = sum + a;
			}
			if(sum % 9 == 0){
				System.out.println("Yes");
			}
			else{
				System.out.println("No");
			}


		}
		stdIn.close();
	}
} public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		String N = stdIn.next();
		if(N.length() < 8){
			long A = new Long(N);
			if(A % 9 == 0){
				System.out.println("Yes");
			}
			else{
				System.out.println("No");
			}
		}
		else{
			int sum = 0;
			int a = 0;
			for(int i = 0; i < N.length(); i++){
				a = N.charAt(i);
				a = a - 48;
				sum = sum + a;
			}
			if(sum % 9 == 0){
				System.out.println("Yes");
			}
			else{
				System.out.println("No");
			}


		}
		stdIn.close();
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		String N = stdIn.next();
		if(N.length() < 8){
			long A = new Long(N);
			if(A % 9 == 0){
				System.out.println("Yes");
			}
			else{
				System.out.println("No");
			}
		}
		else{
			int sum = 0;
			int a = 0;
			for(int i = 0; i < N.length(); i++){
				a = N.charAt(i);
				a = a - 48;
				sum = sum + a;
			}
			if(sum % 9 == 0){
				System.out.println("Yes");
			}
			else{
				System.out.println("No");
			}


		}
		stdIn.close();
	}
}
