import java.util.Scanner;

public class Main {

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

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

} public class Main {

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

}
