import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		
		int sum = 0;
		for (int i = 0; i < n.length(); i++) {
			int num = Integer.valueOf(n.substring(i, i + 1));
			sum += num;
		}
		
		String ans = sum % 9 == 0 ? "Yes" : "No";
		System.out.println(ans);
		
		sc.close();
	}

}

 import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		
		int sum = 0;
		for (int i = 0; i < n.length(); i++) {
			int num = Integer.valueOf(n.substring(i, i + 1));
			sum += num;
		}
		
		String ans = sum % 9 == 0 ? "Yes" : "No";
		System.out.println(ans);
		
		sc.close();
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		
		int sum = 0;
		for (int i = 0; i < n.length(); i++) {
			int num = Integer.valueOf(n.substring(i, i + 1));
			sum += num;
		}
		
		String ans = sum % 9 == 0 ? "Yes" : "No";
		System.out.println(ans);
		
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		
		int sum = 0;
		for (int i = 0; i < n.length(); i++) {
			int num = Integer.valueOf(n.substring(i, i + 1));
			sum += num;
		}
		
		String ans = sum % 9 == 0 ? "Yes" : "No";
		System.out.println(ans);
		
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String n = sc.next(); n sc.next() sc.next sc int sum = 0; sum 0 for (int i = 0; i < n.length(); i++) {
			int num = Integer.valueOf(n.substring(i, i + 1));
			sum += num;
		} int i = 0; int i = 0; i 0 i < n.length() i n.length() n.length n i++ i++ i {
			int num = Integer.valueOf(n.substring(i, i + 1));
			sum += num;
		} {
			int num = Integer.valueOf(n.substring(i, i + 1));
			sum += num;
		} int num = Integer.valueOf(n.substring(i, i + 1)); num Integer.valueOf(n.substring(i, i + 1)) Integer.valueOf Integer n.substring(i, i + 1) n.substring n i i + 1 i 1 sum += num sum num String ans = sum % 9 == 0 ? "Yes" : "No"; ans sum % 9 == 0 ? "Yes" : "No" sum % 9 == 0 sum % 9 sum 9 0 "Yes" "No" System.out.println(ans) System.out.println System.out System System.out ans sc.close() sc.close sc String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		
		int sum = 0;
		for (int i = 0; i < n.length(); i++) {
			int num = Integer.valueOf(n.substring(i, i + 1));
			sum += num;
		}
		
		String ans = sum % 9 == 0 ? "Yes" : "No";
		System.out.println(ans);
		
		sc.close();
	}

} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		
		int sum = 0;
		for (int i = 0; i < n.length(); i++) {
			int num = Integer.valueOf(n.substring(i, i + 1));
			sum += num;
		}
		
		String ans = sum % 9 == 0 ? "Yes" : "No";
		System.out.println(ans);
		
		sc.close();
	}

} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		
		int sum = 0;
		for (int i = 0; i < n.length(); i++) {
			int num = Integer.valueOf(n.substring(i, i + 1));
			sum += num;
		}
		
		String ans = sum % 9 == 0 ? "Yes" : "No";
		System.out.println(ans);
		
		sc.close();
	}

}


