import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		String answer = "";

		try {

			String N = sc.next();
			int judge = 0;

			if(N.equals("0")) {
				answer = "Yes";
			}else {

				for(int i = 0; i < N.length(); i++) {
					int num = ((int) N.charAt(i)) - 48;
					judge += num;
					if(judge >= 9) {
						judge %= 9;
					}
					/*
					System.out.println("num " + num );
					System.out.println("judge " + judge);
					*/
				}
				if(judge == 0) {
					answer = "Yes";
				}else {
					answer = "No";
				}
			}

		}finally {
			sc.close();
			System.out.println(answer);
		}
	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		String answer = "";

		try {

			String N = sc.next();
			int judge = 0;

			if(N.equals("0")) {
				answer = "Yes";
			}else {

				for(int i = 0; i < N.length(); i++) {
					int num = ((int) N.charAt(i)) - 48;
					judge += num;
					if(judge >= 9) {
						judge %= 9;
					}
					/*
					System.out.println("num " + num );
					System.out.println("judge " + judge);
					*/
				}
				if(judge == 0) {
					answer = "Yes";
				}else {
					answer = "No";
				}
			}

		}finally {
			sc.close();
			System.out.println(answer);
		}
	}

} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		String answer = "";

		try {

			String N = sc.next();
			int judge = 0;

			if(N.equals("0")) {
				answer = "Yes";
			}else {

				for(int i = 0; i < N.length(); i++) {
					int num = ((int) N.charAt(i)) - 48;
					judge += num;
					if(judge >= 9) {
						judge %= 9;
					}
					/*
					System.out.println("num " + num );
					System.out.println("judge " + judge);
					*/
				}
				if(judge == 0) {
					answer = "Yes";
				}else {
					answer = "No";
				}
			}

		}finally {
			sc.close();
			System.out.println(answer);
		}
	} main {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		String answer = "";

		try {

			String N = sc.next();
			int judge = 0;

			if(N.equals("0")) {
				answer = "Yes";
			}else {

				for(int i = 0; i < N.length(); i++) {
					int num = ((int) N.charAt(i)) - 48;
					judge += num;
					if(judge >= 9) {
						judge %= 9;
					}
					/*
					System.out.println("num " + num );
					System.out.println("judge " + judge);
					*/
				}
				if(judge == 0) {
					answer = "Yes";
				}else {
					answer = "No";
				}
			}

		}finally {
			sc.close();
			System.out.println(answer);
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String answer = ""; answer "" try {

			String N = sc.next();
			int judge = 0;

			if(N.equals("0")) {
				answer = "Yes";
			}else {

				for(int i = 0; i < N.length(); i++) {
					int num = ((int) N.charAt(i)) - 48;
					judge += num;
					if(judge >= 9) {
						judge %= 9;
					}
					/*
					System.out.println("num " + num );
					System.out.println("judge " + judge);
					*/
				}
				if(judge == 0) {
					answer = "Yes";
				}else {
					answer = "No";
				}
			}

		}finally {
			sc.close();
			System.out.println(answer);
		} {
			sc.close();
			System.out.println(answer);
		} sc.close() sc.close sc System.out.println(answer) System.out.println System.out System System.out answer {

			String N = sc.next();
			int judge = 0;

			if(N.equals("0")) {
				answer = "Yes";
			}else {

				for(int i = 0; i < N.length(); i++) {
					int num = ((int) N.charAt(i)) - 48;
					judge += num;
					if(judge >= 9) {
						judge %= 9;
					}
					/*
					System.out.println("num " + num );
					System.out.println("judge " + judge);
					*/
				}
				if(judge == 0) {
					answer = "Yes";
				}else {
					answer = "No";
				}
			}

		} String N = sc.next(); N sc.next() sc.next sc int judge = 0; judge 0 if(N.equals("0")) {
				answer = "Yes";
			}else {

				for(int i = 0; i < N.length(); i++) {
					int num = ((int) N.charAt(i)) - 48;
					judge += num;
					if(judge >= 9) {
						judge %= 9;
					}
					/*
					System.out.println("num " + num );
					System.out.println("judge " + judge);
					*/
				}
				if(judge == 0) {
					answer = "Yes";
				}else {
					answer = "No";
				}
			} N.equals("0") N.equals N "0" {
				answer = "Yes";
			} answer = "Yes" answer "Yes" {

				for(int i = 0; i < N.length(); i++) {
					int num = ((int) N.charAt(i)) - 48;
					judge += num;
					if(judge >= 9) {
						judge %= 9;
					}
					/*
					System.out.println("num " + num );
					System.out.println("judge " + judge);
					*/
				}
				if(judge == 0) {
					answer = "Yes";
				}else {
					answer = "No";
				}
			} for(int i = 0; i < N.length(); i++) {
					int num = ((int) N.charAt(i)) - 48;
					judge += num;
					if(judge >= 9) {
						judge %= 9;
					}
					/*
					System.out.println("num " + num );
					System.out.println("judge " + judge);
					*/
				} int i = 0; int i = 0; i 0 i < N.length() i N.length() N.length N i++ i++ i {
					int num = ((int) N.charAt(i)) - 48;
					judge += num;
					if(judge >= 9) {
						judge %= 9;
					}
					/*
					System.out.println("num " + num );
					System.out.println("judge " + judge);
					*/
				} {
					int num = ((int) N.charAt(i)) - 48;
					judge += num;
					if(judge >= 9) {
						judge %= 9;
					}
					/*
					System.out.println("num " + num );
					System.out.println("judge " + judge);
					*/
				} int num = ((int) N.charAt(i)) - 48; num ((int) N.charAt(i)) - 48 ((int) N.charAt(i)) N.charAt N i 48 judge += num judge num if(judge >= 9) {
						judge %= 9;
					} judge >= 9 judge 9 {
						judge %= 9;
					} judge %= 9 judge 9 if(judge == 0) {
					answer = "Yes";
				}else {
					answer = "No";
				} judge == 0 judge 0 {
					answer = "Yes";
				} answer = "Yes" answer "Yes" {
					answer = "No";
				} answer = "No" answer "No" String[] args args public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		String answer = "";

		try {

			String N = sc.next();
			int judge = 0;

			if(N.equals("0")) {
				answer = "Yes";
			}else {

				for(int i = 0; i < N.length(); i++) {
					int num = ((int) N.charAt(i)) - 48;
					judge += num;
					if(judge >= 9) {
						judge %= 9;
					}
					/*
					System.out.println("num " + num );
					System.out.println("judge " + judge);
					*/
				}
				if(judge == 0) {
					answer = "Yes";
				}else {
					answer = "No";
				}
			}

		}finally {
			sc.close();
			System.out.println(answer);
		}
	}

} public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		String answer = "";

		try {

			String N = sc.next();
			int judge = 0;

			if(N.equals("0")) {
				answer = "Yes";
			}else {

				for(int i = 0; i < N.length(); i++) {
					int num = ((int) N.charAt(i)) - 48;
					judge += num;
					if(judge >= 9) {
						judge %= 9;
					}
					/*
					System.out.println("num " + num );
					System.out.println("judge " + judge);
					*/
				}
				if(judge == 0) {
					answer = "Yes";
				}else {
					answer = "No";
				}
			}

		}finally {
			sc.close();
			System.out.println(answer);
		}
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		String answer = "";

		try {

			String N = sc.next();
			int judge = 0;

			if(N.equals("0")) {
				answer = "Yes";
			}else {

				for(int i = 0; i < N.length(); i++) {
					int num = ((int) N.charAt(i)) - 48;
					judge += num;
					if(judge >= 9) {
						judge %= 9;
					}
					/*
					System.out.println("num " + num );
					System.out.println("judge " + judge);
					*/
				}
				if(judge == 0) {
					answer = "Yes";
				}else {
					answer = "No";
				}
			}

		}finally {
			sc.close();
			System.out.println(answer);
		}
	}

}
