import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
			
			String s = sc.next();
			
			long sum = 0;
			
			for(int i = 0 ; i < s.length() ; i++ ) {
				char c = s.charAt(i);
				int digit = c - '0';
				sum += digit;
			}
			
			System.out.println(sum % 9 == 0 ? "Yes" : "No");
		}
	}

} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
			
			String s = sc.next();
			
			long sum = 0;
			
			for(int i = 0 ; i < s.length() ; i++ ) {
				char c = s.charAt(i);
				int digit = c - '0';
				sum += digit;
			}
			
			System.out.println(sum % 9 == 0 ? "Yes" : "No");
		}
	}

} Main public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
			
			String s = sc.next();
			
			long sum = 0;
			
			for(int i = 0 ; i < s.length() ; i++ ) {
				char c = s.charAt(i);
				int digit = c - '0';
				sum += digit;
			}
			
			System.out.println(sum % 9 == 0 ? "Yes" : "No");
		}
	} main {
		try(Scanner sc = new Scanner(System.in)) {
			
			String s = sc.next();
			
			long sum = 0;
			
			for(int i = 0 ; i < s.length() ; i++ ) {
				char c = s.charAt(i);
				int digit = c - '0';
				sum += digit;
			}
			
			System.out.println(sum % 9 == 0 ? "Yes" : "No");
		}
	} try(Scanner sc = new Scanner(System.in)) {
			
			String s = sc.next();
			
			long sum = 0;
			
			for(int i = 0 ; i < s.length() ; i++ ) {
				char c = s.charAt(i);
				int digit = c - '0';
				sum += digit;
			}
			
			System.out.println(sum % 9 == 0 ? "Yes" : "No");
		} {
			
			String s = sc.next();
			
			long sum = 0;
			
			for(int i = 0 ; i < s.length() ; i++ ) {
				char c = s.charAt(i);
				int digit = c - '0';
				sum += digit;
			}
			
			System.out.println(sum % 9 == 0 ? "Yes" : "No");
		} Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc long sum = 0; sum 0 for(int i = 0 ; i < s.length() ; i++ ) {
				char c = s.charAt(i);
				int digit = c - '0';
				sum += digit;
			} int i = 0 ; int i = 0 ; i 0 i < s.length() i s.length() s.length s i++ i++ i {
				char c = s.charAt(i);
				int digit = c - '0';
				sum += digit;
			} {
				char c = s.charAt(i);
				int digit = c - '0';
				sum += digit;
			} char c = s.charAt(i); c s.charAt(i) s.charAt s i int digit = c - '0'; digit c - '0' c '0' sum += digit sum digit System.out.println(sum % 9 == 0 ? "Yes" : "No") System.out.println System.out System System.out sum % 9 == 0 ? "Yes" : "No" sum % 9 == 0 sum % 9 sum 9 0 "Yes" "No" String[] args args public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
			
			String s = sc.next();
			
			long sum = 0;
			
			for(int i = 0 ; i < s.length() ; i++ ) {
				char c = s.charAt(i);
				int digit = c - '0';
				sum += digit;
			}
			
			System.out.println(sum % 9 == 0 ? "Yes" : "No");
		}
	}

} public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
			
			String s = sc.next();
			
			long sum = 0;
			
			for(int i = 0 ; i < s.length() ; i++ ) {
				char c = s.charAt(i);
				int digit = c - '0';
				sum += digit;
			}
			
			System.out.println(sum % 9 == 0 ? "Yes" : "No");
		}
	}

} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
			
			String s = sc.next();
			
			long sum = 0;
			
			for(int i = 0 ; i < s.length() ; i++ ) {
				char c = s.charAt(i);
				int digit = c - '0';
				sum += digit;
			}
			
			System.out.println(sum % 9 == 0 ? "Yes" : "No");
		}
	}

}