import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		String number = input.next();

		long sum = 0;

		for (int i = 0; i < number.length(); i++){
			sum += Character.getNumericValue(number.charAt(i));
		}
		System.out.println(sum % 9 == 0 ? "Yes" : "No");
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		String number = input.next();

		long sum = 0;

		for (int i = 0; i < number.length(); i++){
			sum += Character.getNumericValue(number.charAt(i));
		}
		System.out.println(sum % 9 == 0 ? "Yes" : "No");
	}
} Main public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		String number = input.next();

		long sum = 0;

		for (int i = 0; i < number.length(); i++){
			sum += Character.getNumericValue(number.charAt(i));
		}
		System.out.println(sum % 9 == 0 ? "Yes" : "No");
	} main {
		Scanner input = new Scanner(System.in);
		String number = input.next();

		long sum = 0;

		for (int i = 0; i < number.length(); i++){
			sum += Character.getNumericValue(number.charAt(i));
		}
		System.out.println(sum % 9 == 0 ? "Yes" : "No");
	} Scanner input = new Scanner(System.in); input new Scanner(System.in) String number = input.next(); number input.next() input.next input long sum = 0; sum 0 for (int i = 0; i < number.length(); i++){
			sum += Character.getNumericValue(number.charAt(i));
		} int i = 0; int i = 0; i 0 i < number.length() i number.length() number.length number i++ i++ i {
			sum += Character.getNumericValue(number.charAt(i));
		} {
			sum += Character.getNumericValue(number.charAt(i));
		} sum += Character.getNumericValue(number.charAt(i)) sum Character.getNumericValue(number.charAt(i)) Character.getNumericValue Character number.charAt(i) number.charAt number i 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" String[] args args public class Main {
	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		String number = input.next();

		long sum = 0;

		for (int i = 0; i < number.length(); i++){
			sum += Character.getNumericValue(number.charAt(i));
		}
		System.out.println(sum % 9 == 0 ? "Yes" : "No");
	}
} public class Main {
	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		String number = input.next();

		long sum = 0;

		for (int i = 0; i < number.length(); i++){
			sum += Character.getNumericValue(number.charAt(i));
		}
		System.out.println(sum % 9 == 0 ? "Yes" : "No");
	}
} Main
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		String number = input.next();

		long sum = 0;

		for (int i = 0; i < number.length(); i++){
			sum += Character.getNumericValue(number.charAt(i));
		}
		System.out.println(sum % 9 == 0 ? "Yes" : "No");
	}
}