import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.nextLine();
		int total = 0;
		for (int i = 0;i< n.length();i++) {
			total += Integer.parseInt(Character.toString(n.charAt(i)));
		}
		if(total % 9 ==0) {
			System.out.print("Yes");
		}else {

			System.out.print("No");
		}
		
	}

} import java.util.*; util.* java public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.nextLine();
		int total = 0;
		for (int i = 0;i< n.length();i++) {
			total += Integer.parseInt(Character.toString(n.charAt(i)));
		}
		if(total % 9 ==0) {
			System.out.print("Yes");
		}else {

			System.out.print("No");
		}
		
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.nextLine();
		int total = 0;
		for (int i = 0;i< n.length();i++) {
			total += Integer.parseInt(Character.toString(n.charAt(i)));
		}
		if(total % 9 ==0) {
			System.out.print("Yes");
		}else {

			System.out.print("No");
		}
		
	} main {
		Scanner sc = new Scanner(System.in);
		String n = sc.nextLine();
		int total = 0;
		for (int i = 0;i< n.length();i++) {
			total += Integer.parseInt(Character.toString(n.charAt(i)));
		}
		if(total % 9 ==0) {
			System.out.print("Yes");
		}else {

			System.out.print("No");
		}
		
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String n = sc.nextLine(); n sc.nextLine() sc.nextLine sc int total = 0; total 0 for (int i = 0;i< n.length();i++) {
			total += Integer.parseInt(Character.toString(n.charAt(i)));
		} int i = 0; int i = 0; i 0 i< n.length() i n.length() n.length n i++ i++ i {
			total += Integer.parseInt(Character.toString(n.charAt(i)));
		} {
			total += Integer.parseInt(Character.toString(n.charAt(i)));
		} total += Integer.parseInt(Character.toString(n.charAt(i))) total Integer.parseInt(Character.toString(n.charAt(i))) Integer.parseInt Integer Character.toString(n.charAt(i)) Character.toString Character n.charAt(i) n.charAt n i if(total % 9 ==0) {
			System.out.print("Yes");
		}else {

			System.out.print("No");
		} total % 9 ==0 total % 9 total 9 0 {
			System.out.print("Yes");
		} System.out.print("Yes") System.out.print System.out System System.out "Yes" {

			System.out.print("No");
		} System.out.print("No") System.out.print 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 = sc.nextLine();
		int total = 0;
		for (int i = 0;i< n.length();i++) {
			total += Integer.parseInt(Character.toString(n.charAt(i)));
		}
		if(total % 9 ==0) {
			System.out.print("Yes");
		}else {

			System.out.print("No");
		}
		
	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.nextLine();
		int total = 0;
		for (int i = 0;i< n.length();i++) {
			total += Integer.parseInt(Character.toString(n.charAt(i)));
		}
		if(total % 9 ==0) {
			System.out.print("Yes");
		}else {

			System.out.print("No");
		}
		
	}

} Main
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.nextLine();
		int total = 0;
		for (int i = 0;i< n.length();i++) {
			total += Integer.parseInt(Character.toString(n.charAt(i)));
		}
		if(total % 9 ==0) {
			System.out.print("Yes");
		}else {

			System.out.print("No");
		}
		
	}

}