import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		int t = 0;
		String ans;
		for(int i =0; i<N.length(); i++) {
			t += Character.getNumericValue(N.charAt(i));
		}

		if (t%9 == 0) {
			ans = "Yes";
		}else {
			ans = "No";
		}
		System.out.println(ans);
		sc.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		int t = 0;
		String ans;
		for(int i =0; i<N.length(); i++) {
			t += Character.getNumericValue(N.charAt(i));
		}

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

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

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

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

		if (t%9 == 0) {
			ans = "Yes";
		}else {
			ans = "No";
		}
		System.out.println(ans);
		sc.close();
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		int t = 0;
		String ans;
		for(int i =0; i<N.length(); i++) {
			t += Character.getNumericValue(N.charAt(i));
		}

		if (t%9 == 0) {
			ans = "Yes";
		}else {
			ans = "No";
		}
		System.out.println(ans);
		sc.close();
	}
}
