import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String num = scan.next();
		long sum = 0;
		for(char c : num.toCharArray()) sum+=(c-'0');
		System.out.println(sum%9 == 0 ? "Yes" : "No");
		scan.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String num = scan.next();
		long sum = 0;
		for(char c : num.toCharArray()) sum+=(c-'0');
		System.out.println(sum%9 == 0 ? "Yes" : "No");
		scan.close();
	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String num = scan.next();
		long sum = 0;
		for(char c : num.toCharArray()) sum+=(c-'0');
		System.out.println(sum%9 == 0 ? "Yes" : "No");
		scan.close();
	} main {
		Scanner scan = new Scanner(System.in);
		String num = scan.next();
		long sum = 0;
		for(char c : num.toCharArray()) sum+=(c-'0');
		System.out.println(sum%9 == 0 ? "Yes" : "No");
		scan.close();
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String num = scan.next(); num scan.next() scan.next scan long sum = 0; sum 0 for(char c : num.toCharArray()) sum+=(c-'0'); char c num.toCharArray() num.toCharArray num sum+=(c-'0'); sum+=(c-'0') sum (c-'0') c '0' 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" scan.close() scan.close scan String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String num = scan.next();
		long sum = 0;
		for(char c : num.toCharArray()) sum+=(c-'0');
		System.out.println(sum%9 == 0 ? "Yes" : "No");
		scan.close();
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String num = scan.next();
		long sum = 0;
		for(char c : num.toCharArray()) sum+=(c-'0');
		System.out.println(sum%9 == 0 ? "Yes" : "No");
		scan.close();
	}
} Main
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String num = scan.next();
		long sum = 0;
		for(char c : num.toCharArray()) sum+=(c-'0');
		System.out.println(sum%9 == 0 ? "Yes" : "No");
		scan.close();
	}
}