import java.util.Scanner;

public class Main {

	static int ans;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		int sum = 0;
		for(int i = 0; i<n.length();i++) {
			int tmp= Character.getNumericValue(n.charAt(i));
//			System.out.println(tmp);
			sum+=tmp;
		}
//		System.out.println(sum);
		if(sum%9==0) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		
//		System.out.println(ans);
	}
} import java.util.Scanner; Scanner java.util public class Main {

	static int ans;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		int sum = 0;
		for(int i = 0; i<n.length();i++) {
			int tmp= Character.getNumericValue(n.charAt(i));
//			System.out.println(tmp);
			sum+=tmp;
		}
//		System.out.println(sum);
		if(sum%9==0) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		
//		System.out.println(ans);
	}
} Main static int ans; ans public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		int sum = 0;
		for(int i = 0; i<n.length();i++) {
			int tmp= Character.getNumericValue(n.charAt(i));
//			System.out.println(tmp);
			sum+=tmp;
		}
//		System.out.println(sum);
		if(sum%9==0) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		
//		System.out.println(ans);
	} main {

		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		int sum = 0;
		for(int i = 0; i<n.length();i++) {
			int tmp= Character.getNumericValue(n.charAt(i));
//			System.out.println(tmp);
			sum+=tmp;
		}
//		System.out.println(sum);
		if(sum%9==0) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		
//		System.out.println(ans);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String n = sc.next(); n sc.next() sc.next sc int sum = 0; sum 0 for(int i = 0; i<n.length();i++) {
			int tmp= Character.getNumericValue(n.charAt(i));
//			System.out.println(tmp);
			sum+=tmp;
		} int i = 0; int i = 0; i 0 i<n.length() i n.length() n.length n i++ i++ i {
			int tmp= Character.getNumericValue(n.charAt(i));
//			System.out.println(tmp);
			sum+=tmp;
		} {
			int tmp= Character.getNumericValue(n.charAt(i));
//			System.out.println(tmp);
			sum+=tmp;
		} int tmp= Character.getNumericValue(n.charAt(i)); tmp Character.getNumericValue(n.charAt(i)) Character.getNumericValue Character n.charAt(i) n.charAt n i sum+=tmp sum tmp 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 {

	static int ans;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		int sum = 0;
		for(int i = 0; i<n.length();i++) {
			int tmp= Character.getNumericValue(n.charAt(i));
//			System.out.println(tmp);
			sum+=tmp;
		}
//		System.out.println(sum);
		if(sum%9==0) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		
//		System.out.println(ans);
	}
} public class Main {

	static int ans;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		int sum = 0;
		for(int i = 0; i<n.length();i++) {
			int tmp= Character.getNumericValue(n.charAt(i));
//			System.out.println(tmp);
			sum+=tmp;
		}
//		System.out.println(sum);
		if(sum%9==0) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		
//		System.out.println(ans);
	}
} Main
import java.util.Scanner;

public class Main {

	static int ans;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		int sum = 0;
		for(int i = 0; i<n.length();i++) {
			int tmp= Character.getNumericValue(n.charAt(i));
//			System.out.println(tmp);
			sum+=tmp;
		}
//		System.out.println(sum);
		if(sum%9==0) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		
//		System.out.println(ans);
	}
}