import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try(Scanner scanner = new Scanner(System.in)) {
			String data = scanner.nextLine();

			char[] chars = data.toCharArray();

			int total = 0;
			for (int i = 0; i < chars.length; i++) {
				int n = Integer.parseInt(String.valueOf(chars[i]));
				total += n;
			}

			System.out.println(total % 9 == 0 ? "Yes" : "No");
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		try(Scanner scanner = new Scanner(System.in)) {
			String data = scanner.nextLine();

			char[] chars = data.toCharArray();

			int total = 0;
			for (int i = 0; i < chars.length; i++) {
				int n = Integer.parseInt(String.valueOf(chars[i]));
				total += n;
			}

			System.out.println(total % 9 == 0 ? "Yes" : "No");
		}
	}
} Main public static void main(String[] args) {
		try(Scanner scanner = new Scanner(System.in)) {
			String data = scanner.nextLine();

			char[] chars = data.toCharArray();

			int total = 0;
			for (int i = 0; i < chars.length; i++) {
				int n = Integer.parseInt(String.valueOf(chars[i]));
				total += n;
			}

			System.out.println(total % 9 == 0 ? "Yes" : "No");
		}
	} main {
		try(Scanner scanner = new Scanner(System.in)) {
			String data = scanner.nextLine();

			char[] chars = data.toCharArray();

			int total = 0;
			for (int i = 0; i < chars.length; i++) {
				int n = Integer.parseInt(String.valueOf(chars[i]));
				total += n;
			}

			System.out.println(total % 9 == 0 ? "Yes" : "No");
		}
	} try(Scanner scanner = new Scanner(System.in)) {
			String data = scanner.nextLine();

			char[] chars = data.toCharArray();

			int total = 0;
			for (int i = 0; i < chars.length; i++) {
				int n = Integer.parseInt(String.valueOf(chars[i]));
				total += n;
			}

			System.out.println(total % 9 == 0 ? "Yes" : "No");
		} {
			String data = scanner.nextLine();

			char[] chars = data.toCharArray();

			int total = 0;
			for (int i = 0; i < chars.length; i++) {
				int n = Integer.parseInt(String.valueOf(chars[i]));
				total += n;
			}

			System.out.println(total % 9 == 0 ? "Yes" : "No");
		} Scanner scanner = new Scanner(System.in) Scanner scanner = new Scanner(System.in) new Scanner(System.in) String data = scanner.nextLine(); data scanner.nextLine() scanner.nextLine scanner char[] chars = data.toCharArray(); chars data.toCharArray() data.toCharArray data int total = 0; total 0 for (int i = 0; i < chars.length; i++) {
				int n = Integer.parseInt(String.valueOf(chars[i]));
				total += n;
			} int i = 0; int i = 0; i 0 i < chars.length i chars.length chars chars.length i++ i++ i {
				int n = Integer.parseInt(String.valueOf(chars[i]));
				total += n;
			} {
				int n = Integer.parseInt(String.valueOf(chars[i]));
				total += n;
			} int n = Integer.parseInt(String.valueOf(chars[i])); n Integer.parseInt(String.valueOf(chars[i])) Integer.parseInt Integer String.valueOf(chars[i]) String.valueOf String chars[i] chars i total += n total n System.out.println(total % 9 == 0 ? "Yes" : "No") System.out.println System.out System System.out total % 9 == 0 ? "Yes" : "No" total % 9 == 0 total % 9 total 9 0 "Yes" "No" String[] args args public class Main {

	public static void main(String[] args) {
		try(Scanner scanner = new Scanner(System.in)) {
			String data = scanner.nextLine();

			char[] chars = data.toCharArray();

			int total = 0;
			for (int i = 0; i < chars.length; i++) {
				int n = Integer.parseInt(String.valueOf(chars[i]));
				total += n;
			}

			System.out.println(total % 9 == 0 ? "Yes" : "No");
		}
	}
} public class Main {

	public static void main(String[] args) {
		try(Scanner scanner = new Scanner(System.in)) {
			String data = scanner.nextLine();

			char[] chars = data.toCharArray();

			int total = 0;
			for (int i = 0; i < chars.length; i++) {
				int n = Integer.parseInt(String.valueOf(chars[i]));
				total += n;
			}

			System.out.println(total % 9 == 0 ? "Yes" : "No");
		}
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try(Scanner scanner = new Scanner(System.in)) {
			String data = scanner.nextLine();

			char[] chars = data.toCharArray();

			int total = 0;
			for (int i = 0; i < chars.length; i++) {
				int n = Integer.parseInt(String.valueOf(chars[i]));
				total += n;
			}

			System.out.println(total % 9 == 0 ? "Yes" : "No");
		}
	}
}