import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String N = scanner.next();
		String[] splitArray = N.split("");
		int sum = 0;

 		for (int i = 0; i < splitArray.length; i++) {
 			//System.out.println(splitArray[i]);
 			sum += Integer.parseInt(splitArray[i]);
 		}
 		//System.out.println(sum);


		if (sum % 9 == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String N = scanner.next();
		String[] splitArray = N.split("");
		int sum = 0;

 		for (int i = 0; i < splitArray.length; i++) {
 			//System.out.println(splitArray[i]);
 			sum += Integer.parseInt(splitArray[i]);
 		}
 		//System.out.println(sum);


		if (sum % 9 == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
} Main public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String N = scanner.next();
		String[] splitArray = N.split("");
		int sum = 0;

 		for (int i = 0; i < splitArray.length; i++) {
 			//System.out.println(splitArray[i]);
 			sum += Integer.parseInt(splitArray[i]);
 		}
 		//System.out.println(sum);


		if (sum % 9 == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	} main {
		Scanner scanner = new Scanner(System.in);
		String N = scanner.next();
		String[] splitArray = N.split("");
		int sum = 0;

 		for (int i = 0; i < splitArray.length; i++) {
 			//System.out.println(splitArray[i]);
 			sum += Integer.parseInt(splitArray[i]);
 		}
 		//System.out.println(sum);


		if (sum % 9 == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String N = scanner.next(); N scanner.next() scanner.next scanner String[] splitArray = N.split(""); splitArray N.split("") N.split N "" int sum = 0; sum 0 for (int i = 0; i < splitArray.length; i++) {
 			//System.out.println(splitArray[i]);
 			sum += Integer.parseInt(splitArray[i]);
 		} int i = 0; int i = 0; i 0 i < splitArray.length i splitArray.length splitArray splitArray.length i++ i++ i {
 			//System.out.println(splitArray[i]);
 			sum += Integer.parseInt(splitArray[i]);
 		} {
 			//System.out.println(splitArray[i]);
 			sum += Integer.parseInt(splitArray[i]);
 		} sum += Integer.parseInt(splitArray[i]) sum Integer.parseInt(splitArray[i]) Integer.parseInt Integer splitArray[i] splitArray 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" String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String N = scanner.next();
		String[] splitArray = N.split("");
		int sum = 0;

 		for (int i = 0; i < splitArray.length; i++) {
 			//System.out.println(splitArray[i]);
 			sum += Integer.parseInt(splitArray[i]);
 		}
 		//System.out.println(sum);


		if (sum % 9 == 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 N = scanner.next();
		String[] splitArray = N.split("");
		int sum = 0;

 		for (int i = 0; i < splitArray.length; i++) {
 			//System.out.println(splitArray[i]);
 			sum += Integer.parseInt(splitArray[i]);
 		}
 		//System.out.println(sum);


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

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String N = scanner.next();
		String[] splitArray = N.split("");
		int sum = 0;

 		for (int i = 0; i < splitArray.length; i++) {
 			//System.out.println(splitArray[i]);
 			sum += Integer.parseInt(splitArray[i]);
 		}
 		//System.out.println(sum);


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