import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		String S = sc.next();
		char[] C = S.toCharArray();

		int ans = 0;

		for(int i=0;i<S.length();i++) {

			int x = C[i]-48;
			ans = (ans + x)%9;

		}
		if(ans==0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
} import java.io.FileNotFoundException; FileNotFoundException java.io import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		String S = sc.next();
		char[] C = S.toCharArray();

		int ans = 0;

		for(int i=0;i<S.length();i++) {

			int x = C[i]-48;
			ans = (ans + x)%9;

		}
		if(ans==0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
} Main public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		String S = sc.next();
		char[] C = S.toCharArray();

		int ans = 0;

		for(int i=0;i<S.length();i++) {

			int x = C[i]-48;
			ans = (ans + x)%9;

		}
		if(ans==0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	} main {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		String S = sc.next();
		char[] C = S.toCharArray();

		int ans = 0;

		for(int i=0;i<S.length();i++) {

			int x = C[i]-48;
			ans = (ans + x)%9;

		}
		if(ans==0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String S = sc.next(); S sc.next() sc.next sc char[] C = S.toCharArray(); C S.toCharArray() S.toCharArray S int ans = 0; ans 0 for(int i=0;i<S.length();i++) {

			int x = C[i]-48;
			ans = (ans + x)%9;

		} int i=0; int i=0; i 0 i<S.length() i S.length() S.length S i++ i++ i {

			int x = C[i]-48;
			ans = (ans + x)%9;

		} {

			int x = C[i]-48;
			ans = (ans + x)%9;

		} int x = C[i]-48; x C[i]-48 C[i] C i 48 ans = (ans + x)%9 ans (ans + x)%9 (ans + x) ans x 9 if(ans==0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		} ans==0 ans 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 {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		String S = sc.next();
		char[] C = S.toCharArray();

		int ans = 0;

		for(int i=0;i<S.length();i++) {

			int x = C[i]-48;
			ans = (ans + x)%9;

		}
		if(ans==0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
} public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		String S = sc.next();
		char[] C = S.toCharArray();

		int ans = 0;

		for(int i=0;i<S.length();i++) {

			int x = C[i]-48;
			ans = (ans + x)%9;

		}
		if(ans==0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
} Main
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		String S = sc.next();
		char[] C = S.toCharArray();

		int ans = 0;

		for(int i=0;i<S.length();i++) {

			int x = C[i]-48;
			ans = (ans + x)%9;

		}
		if(ans==0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}