import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		
		String n = scan.next();
		String[] s = n.split("");
		
		int total = 0;
		
		for(int i = 0; i < s.length; i++) {
			total += Integer.parseInt(s[i]);
		}
		
		if(total % 9 == 0) {
			System.out.print("Yes");
		}
		else {
			System.out.print("No");
		}
	}

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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		
		String n = scan.next();
		String[] s = n.split("");
		
		int total = 0;
		
		for(int i = 0; i < s.length; i++) {
			total += Integer.parseInt(s[i]);
		}
		
		if(total % 9 == 0) {
			System.out.print("Yes");
		}
		else {
			System.out.print("No");
		}
	}

} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		
		String n = scan.next();
		String[] s = n.split("");
		
		int total = 0;
		
		for(int i = 0; i < s.length; i++) {
			total += Integer.parseInt(s[i]);
		}
		
		if(total % 9 == 0) {
			System.out.print("Yes");
		}
		else {
			System.out.print("No");
		}
	} main {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		
		String n = scan.next();
		String[] s = n.split("");
		
		int total = 0;
		
		for(int i = 0; i < s.length; i++) {
			total += Integer.parseInt(s[i]);
		}
		
		if(total % 9 == 0) {
			System.out.print("Yes");
		}
		else {
			System.out.print("No");
		}
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String n = scan.next(); n scan.next() scan.next scan String[] s = n.split(""); s n.split("") n.split n "" int total = 0; total 0 for(int i = 0; i < s.length; i++) {
			total += Integer.parseInt(s[i]);
		} int i = 0; int i = 0; i 0 i < s.length i s.length s s.length i++ i++ i {
			total += Integer.parseInt(s[i]);
		} {
			total += Integer.parseInt(s[i]);
		} total += Integer.parseInt(s[i]) total Integer.parseInt(s[i]) Integer.parseInt Integer s[i] s 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) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		
		String n = scan.next();
		String[] s = n.split("");
		
		int total = 0;
		
		for(int i = 0; i < s.length; i++) {
			total += Integer.parseInt(s[i]);
		}
		
		if(total % 9 == 0) {
			System.out.print("Yes");
		}
		else {
			System.out.print("No");
		}
	}

} public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		
		String n = scan.next();
		String[] s = n.split("");
		
		int total = 0;
		
		for(int i = 0; i < s.length; i++) {
			total += Integer.parseInt(s[i]);
		}
		
		if(total % 9 == 0) {
			System.out.print("Yes");
		}
		else {
			System.out.print("No");
		}
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		
		String n = scan.next();
		String[] s = n.split("");
		
		int total = 0;
		
		for(int i = 0; i < s.length; i++) {
			total += Integer.parseInt(s[i]);
		}
		
		if(total % 9 == 0) {
			System.out.print("Yes");
		}
		else {
			System.out.print("No");
		}
	}

}
