import java.util.Scanner;

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

public class Main {
	public static void main(String args[]) {
		Scanner stdIn = new Scanner(System.in);
		String N = stdIn.nextLine();
		int sum = 0;
		for(int i = 0; i < N.length(); i ++) {
			sum += Integer.parseInt(N.substring(i, i + 1));
		}
		if(sum % 9 == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}