import java.util.Scanner;

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

		String n = scan.next();
		int length = n.length();
		char[] n_list = n.toCharArray();
		long sum = 0;

		for(int i = 0; i < length;i++) {
			sum += (int)n_list[i] - (int)'0';
		}

		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 scan = new Scanner(System.in);

		String n = scan.next();
		int length = n.length();
		char[] n_list = n.toCharArray();
		long sum = 0;

		for(int i = 0; i < length;i++) {
			sum += (int)n_list[i] - (int)'0';
		}

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

		String n = scan.next();
		int length = n.length();
		char[] n_list = n.toCharArray();
		long sum = 0;

		for(int i = 0; i < length;i++) {
			sum += (int)n_list[i] - (int)'0';
		}

		if(sum % 9 == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	} main {
		Scanner scan = new Scanner(System.in);

		String n = scan.next();
		int length = n.length();
		char[] n_list = n.toCharArray();
		long sum = 0;

		for(int i = 0; i < length;i++) {
			sum += (int)n_list[i] - (int)'0';
		}

		if(sum % 9 == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String n = scan.next(); n scan.next() scan.next scan int length = n.length(); length n.length() n.length n char[] n_list = n.toCharArray(); n_list n.toCharArray() n.toCharArray n long sum = 0; sum 0 for(int i = 0; i < length;i++) {
			sum += (int)n_list[i] - (int)'0';
		} int i = 0; int i = 0; i 0 i < length i length i++ i++ i {
			sum += (int)n_list[i] - (int)'0';
		} {
			sum += (int)n_list[i] - (int)'0';
		} sum += (int)n_list[i] - (int)'0' sum (int)n_list[i] - (int)'0' (int)n_list[i] n_list i (int)'0' 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 scan = new Scanner(System.in);

		String n = scan.next();
		int length = n.length();
		char[] n_list = n.toCharArray();
		long sum = 0;

		for(int i = 0; i < length;i++) {
			sum += (int)n_list[i] - (int)'0';
		}

		if(sum % 9 == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		String n = scan.next();
		int length = n.length();
		char[] n_list = n.toCharArray();
		long sum = 0;

		for(int i = 0; i < length;i++) {
			sum += (int)n_list[i] - (int)'0';
		}

		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 scan = new Scanner(System.in);

		String n = scan.next();
		int length = n.length();
		char[] n_list = n.toCharArray();
		long sum = 0;

		for(int i = 0; i < length;i++) {
			sum += (int)n_list[i] - (int)'0';
		}

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