import java.util.Scanner;

public class Main {

	static String solve(String n) {

		int num = 0;
		char[] cha = n.toCharArray();
		for (int i = 0; i < cha.length; i++) {
			num += cha[i] - 48;
		}
		if (num % 9 == 0)
			return "Yes";
		else
			return "No";
	}

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String n = stdIn.next();
		String result = solve(n);
		System.out.println(result);

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

	static String solve(String n) {

		int num = 0;
		char[] cha = n.toCharArray();
		for (int i = 0; i < cha.length; i++) {
			num += cha[i] - 48;
		}
		if (num % 9 == 0)
			return "Yes";
		else
			return "No";
	}

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String n = stdIn.next();
		String result = solve(n);
		System.out.println(result);

		stdIn.close();
	}
} Main static String solve(String n) {

		int num = 0;
		char[] cha = n.toCharArray();
		for (int i = 0; i < cha.length; i++) {
			num += cha[i] - 48;
		}
		if (num % 9 == 0)
			return "Yes";
		else
			return "No";
	} solve {

		int num = 0;
		char[] cha = n.toCharArray();
		for (int i = 0; i < cha.length; i++) {
			num += cha[i] - 48;
		}
		if (num % 9 == 0)
			return "Yes";
		else
			return "No";
	} int num = 0; num 0 char[] cha = n.toCharArray(); cha n.toCharArray() n.toCharArray n for (int i = 0; i < cha.length; i++) {
			num += cha[i] - 48;
		} int i = 0; int i = 0; i 0 i < cha.length i cha.length cha cha.length i++ i++ i {
			num += cha[i] - 48;
		} {
			num += cha[i] - 48;
		} num += cha[i] - 48 num cha[i] - 48 cha[i] cha i 48 if (num % 9 == 0)
			return "Yes";
		else
			return "No"; num % 9 == 0 num % 9 num 9 0 return "Yes"; "Yes" return "No"; "No" String n n public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String n = stdIn.next();
		String result = solve(n);
		System.out.println(result);

		stdIn.close();
	} main {
		Scanner stdIn = new Scanner(System.in);
		String n = stdIn.next();
		String result = solve(n);
		System.out.println(result);

		stdIn.close();
	} Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) String n = stdIn.next(); n stdIn.next() stdIn.next stdIn String result = solve(n); result solve(n) solve n System.out.println(result) System.out.println System.out System System.out result stdIn.close() stdIn.close stdIn String[] args args public class Main {

	static String solve(String n) {

		int num = 0;
		char[] cha = n.toCharArray();
		for (int i = 0; i < cha.length; i++) {
			num += cha[i] - 48;
		}
		if (num % 9 == 0)
			return "Yes";
		else
			return "No";
	}

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String n = stdIn.next();
		String result = solve(n);
		System.out.println(result);

		stdIn.close();
	}
} public class Main {

	static String solve(String n) {

		int num = 0;
		char[] cha = n.toCharArray();
		for (int i = 0; i < cha.length; i++) {
			num += cha[i] - 48;
		}
		if (num % 9 == 0)
			return "Yes";
		else
			return "No";
	}

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String n = stdIn.next();
		String result = solve(n);
		System.out.println(result);

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

public class Main {

	static String solve(String n) {

		int num = 0;
		char[] cha = n.toCharArray();
		for (int i = 0; i < cha.length; i++) {
			num += cha[i] - 48;
		}
		if (num % 9 == 0)
			return "Yes";
		else
			return "No";
	}

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String n = stdIn.next();
		String result = solve(n);
		System.out.println(result);

		stdIn.close();
	}
}
