import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		String n = reader.next();
		long total = 0;
		for (int i = 0; i < n.length(); i++) {
			total += Integer.parseInt("" + n.charAt(i));
		}
		if (total % 9 == 0) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		reader.close();
	}
	
} import java.util.*; util.* java public class Main {

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		String n = reader.next();
		long total = 0;
		for (int i = 0; i < n.length(); i++) {
			total += Integer.parseInt("" + n.charAt(i));
		}
		if (total % 9 == 0) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		reader.close();
	}
	
} Main public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		String n = reader.next();
		long total = 0;
		for (int i = 0; i < n.length(); i++) {
			total += Integer.parseInt("" + n.charAt(i));
		}
		if (total % 9 == 0) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		reader.close();
	} main {
		Scanner reader = new Scanner(System.in);
		String n = reader.next();
		long total = 0;
		for (int i = 0; i < n.length(); i++) {
			total += Integer.parseInt("" + n.charAt(i));
		}
		if (total % 9 == 0) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		reader.close();
	} Scanner reader = new Scanner(System.in); reader new Scanner(System.in) String n = reader.next(); n reader.next() reader.next reader long total = 0; total 0 for (int i = 0; i < n.length(); i++) {
			total += Integer.parseInt("" + 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("" + n.charAt(i));
		} {
			total += Integer.parseInt("" + n.charAt(i));
		} total += Integer.parseInt("" + n.charAt(i)) total Integer.parseInt("" + n.charAt(i)) Integer.parseInt Integer "" + n.charAt(i) "" n.charAt(i) n.charAt n i if (total % 9 == 0) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		} total % 9 == 0 total % 9 total 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" reader.close() reader.close reader String[] args args public class Main {

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		String n = reader.next();
		long total = 0;
		for (int i = 0; i < n.length(); i++) {
			total += Integer.parseInt("" + n.charAt(i));
		}
		if (total % 9 == 0) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		reader.close();
	}
	
} public class Main {

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		String n = reader.next();
		long total = 0;
		for (int i = 0; i < n.length(); i++) {
			total += Integer.parseInt("" + n.charAt(i));
		}
		if (total % 9 == 0) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		reader.close();
	}
	
} Main
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		String n = reader.next();
		long total = 0;
		for (int i = 0; i < n.length(); i++) {
			total += Integer.parseInt("" + n.charAt(i));
		}
		if (total % 9 == 0) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		reader.close();
	}
	
}
