import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		
		String X = scanner.next();
		
		scanner.close();

		
		String[] tmpList = String.valueOf(X).split("");
		
		int [] ch = new int[tmpList.length];
		
		for (int i = 0; i < tmpList.length; i++) {
			ch[i] = Integer.parseInt(tmpList[i]);
		}
		
		double result2 = java.util.Arrays.stream(ch).sum();
				
		double result = result2 % 9;
		
		if (result == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
		
		
	}

} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
	
	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		
		String X = scanner.next();
		
		scanner.close();

		
		String[] tmpList = String.valueOf(X).split("");
		
		int [] ch = new int[tmpList.length];
		
		for (int i = 0; i < tmpList.length; i++) {
			ch[i] = Integer.parseInt(tmpList[i]);
		}
		
		double result2 = java.util.Arrays.stream(ch).sum();
				
		double result = result2 % 9;
		
		if (result == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
		
		
	}

} Main public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		
		String X = scanner.next();
		
		scanner.close();

		
		String[] tmpList = String.valueOf(X).split("");
		
		int [] ch = new int[tmpList.length];
		
		for (int i = 0; i < tmpList.length; i++) {
			ch[i] = Integer.parseInt(tmpList[i]);
		}
		
		double result2 = java.util.Arrays.stream(ch).sum();
				
		double result = result2 % 9;
		
		if (result == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
		
		
	} main {
		
		Scanner scanner = new Scanner(System.in);
		
		String X = scanner.next();
		
		scanner.close();

		
		String[] tmpList = String.valueOf(X).split("");
		
		int [] ch = new int[tmpList.length];
		
		for (int i = 0; i < tmpList.length; i++) {
			ch[i] = Integer.parseInt(tmpList[i]);
		}
		
		double result2 = java.util.Arrays.stream(ch).sum();
				
		double result = result2 % 9;
		
		if (result == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
		
		
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String X = scanner.next(); X scanner.next() scanner.next scanner scanner.close() scanner.close scanner String[] tmpList = String.valueOf(X).split(""); tmpList String.valueOf(X).split("") String.valueOf(X).split String.valueOf(X) String.valueOf String X "" int [] ch = new int[tmpList.length]; ch new int[tmpList.length] tmpList.length tmpList tmpList.length for (int i = 0; i < tmpList.length; i++) {
			ch[i] = Integer.parseInt(tmpList[i]);
		} int i = 0; int i = 0; i 0 i < tmpList.length i tmpList.length tmpList tmpList.length i++ i++ i {
			ch[i] = Integer.parseInt(tmpList[i]);
		} {
			ch[i] = Integer.parseInt(tmpList[i]);
		} ch[i] = Integer.parseInt(tmpList[i]) ch[i] ch i Integer.parseInt(tmpList[i]) Integer.parseInt Integer tmpList[i] tmpList i double result2 = java.util.Arrays.stream(ch).sum(); result2 java.util.Arrays.stream(ch).sum() java.util.Arrays.stream(ch).sum java.util.Arrays.stream(ch) java.util.Arrays.stream java.util.Arrays java.util java java.util java.util.Arrays ch double result = result2 % 9; result result2 % 9 result2 9 if (result == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		} result == 0 result 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) {
		
		Scanner scanner = new Scanner(System.in);
		
		String X = scanner.next();
		
		scanner.close();

		
		String[] tmpList = String.valueOf(X).split("");
		
		int [] ch = new int[tmpList.length];
		
		for (int i = 0; i < tmpList.length; i++) {
			ch[i] = Integer.parseInt(tmpList[i]);
		}
		
		double result2 = java.util.Arrays.stream(ch).sum();
				
		double result = result2 % 9;
		
		if (result == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
		
		
	}

} public class Main {
	
	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		
		String X = scanner.next();
		
		scanner.close();

		
		String[] tmpList = String.valueOf(X).split("");
		
		int [] ch = new int[tmpList.length];
		
		for (int i = 0; i < tmpList.length; i++) {
			ch[i] = Integer.parseInt(tmpList[i]);
		}
		
		double result2 = java.util.Arrays.stream(ch).sum();
				
		double result = result2 % 9;
		
		if (result == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
		
		
	}

} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		
		String X = scanner.next();
		
		scanner.close();

		
		String[] tmpList = String.valueOf(X).split("");
		
		int [] ch = new int[tmpList.length];
		
		for (int i = 0; i < tmpList.length; i++) {
			ch[i] = Integer.parseInt(tmpList[i]);
		}
		
		double result2 = java.util.Arrays.stream(ch).sum();
				
		double result = result2 % 9;
		
		if (result == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
		
		
	}

}
