import java.util.Scanner;

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

		// 入力値の取得
		String N = sc.next();
		
		char[] NcharArray = N.toCharArray();
		int sum = 0;
		for (int i = 0; i < NcharArray.length; i++) {
			sum +=Character.getNumericValue(NcharArray[i]);
		}
		
		// 結果の出力
		if (sum % 9 == 0) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		
		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();
		
		char[] NcharArray = N.toCharArray();
		int sum = 0;
		for (int i = 0; i < NcharArray.length; i++) {
			sum +=Character.getNumericValue(NcharArray[i]);
		}
		
		// 結果の出力
		if (sum % 9 == 0) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		
		sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		// 入力値の取得
		String N = sc.next();
		
		char[] NcharArray = N.toCharArray();
		int sum = 0;
		for (int i = 0; i < NcharArray.length; i++) {
			sum +=Character.getNumericValue(NcharArray[i]);
		}
		
		// 結果の出力
		if (sum % 9 == 0) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);

		// 入力値の取得
		String N = sc.next();
		
		char[] NcharArray = N.toCharArray();
		int sum = 0;
		for (int i = 0; i < NcharArray.length; i++) {
			sum +=Character.getNumericValue(NcharArray[i]);
		}
		
		// 結果の出力
		if (sum % 9 == 0) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String N = sc.next(); N sc.next() sc.next sc char[] NcharArray = N.toCharArray(); NcharArray N.toCharArray() N.toCharArray N int sum = 0; sum 0 for (int i = 0; i < NcharArray.length; i++) {
			sum +=Character.getNumericValue(NcharArray[i]);
		} int i = 0; int i = 0; i 0 i < NcharArray.length i NcharArray.length NcharArray NcharArray.length i++ i++ i {
			sum +=Character.getNumericValue(NcharArray[i]);
		} {
			sum +=Character.getNumericValue(NcharArray[i]);
		} sum +=Character.getNumericValue(NcharArray[i]) sum Character.getNumericValue(NcharArray[i]) Character.getNumericValue Character NcharArray[i] NcharArray i 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" 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();
		
		char[] NcharArray = N.toCharArray();
		int sum = 0;
		for (int i = 0; i < NcharArray.length; i++) {
			sum +=Character.getNumericValue(NcharArray[i]);
		}
		
		// 結果の出力
		if (sum % 9 == 0) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		
		sc.close();
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		// 入力値の取得
		String N = sc.next();
		
		char[] NcharArray = N.toCharArray();
		int sum = 0;
		for (int i = 0; i < NcharArray.length; i++) {
			sum +=Character.getNumericValue(NcharArray[i]);
		}
		
		// 結果の出力
		if (sum % 9 == 0) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		
		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();
		
		char[] NcharArray = N.toCharArray();
		int sum = 0;
		for (int i = 0; i < NcharArray.length; i++) {
			sum +=Character.getNumericValue(NcharArray[i]);
		}
		
		// 結果の出力
		if (sum % 9 == 0) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		
		sc.close();
	}
}
