import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.nextLine();
		long sum = 0;


		int l = s.length();
		for(int i = 0; i < l; i++) {
			int num = Character.getNumericValue(s.charAt(i));
			sum += num;
		}


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




		scan.close();
	}

} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.nextLine();
		long sum = 0;


		int l = s.length();
		for(int i = 0; i < l; i++) {
			int num = Character.getNumericValue(s.charAt(i));
			sum += num;
		}


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




		scan.close();
	}

} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.nextLine();
		long sum = 0;


		int l = s.length();
		for(int i = 0; i < l; i++) {
			int num = Character.getNumericValue(s.charAt(i));
			sum += num;
		}


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




		scan.close();
	} main {
		Scanner scan = new Scanner(System.in);
		String s = scan.nextLine();
		long sum = 0;


		int l = s.length();
		for(int i = 0; i < l; i++) {
			int num = Character.getNumericValue(s.charAt(i));
			sum += num;
		}


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




		scan.close();
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String s = scan.nextLine(); s scan.nextLine() scan.nextLine scan long sum = 0; sum 0 int l = s.length(); l s.length() s.length s for(int i = 0; i < l; i++) {
			int num = Character.getNumericValue(s.charAt(i));
			sum += num;
		} int i = 0; int i = 0; i 0 i < l i l i++ i++ i {
			int num = Character.getNumericValue(s.charAt(i));
			sum += num;
		} {
			int num = Character.getNumericValue(s.charAt(i));
			sum += num;
		} int num = Character.getNumericValue(s.charAt(i)); num Character.getNumericValue(s.charAt(i)) Character.getNumericValue Character s.charAt(i) s.charAt s i sum += num sum num 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" scan.close() scan.close scan String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.nextLine();
		long sum = 0;


		int l = s.length();
		for(int i = 0; i < l; i++) {
			int num = Character.getNumericValue(s.charAt(i));
			sum += num;
		}


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




		scan.close();
	}

} public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.nextLine();
		long sum = 0;


		int l = s.length();
		for(int i = 0; i < l; i++) {
			int num = Character.getNumericValue(s.charAt(i));
			sum += num;
		}


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




		scan.close();
	}

} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.nextLine();
		long sum = 0;


		int l = s.length();
		for(int i = 0; i < l; i++) {
			int num = Character.getNumericValue(s.charAt(i));
			sum += num;
		}


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




		scan.close();
	}

}
