
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String n = sc.nextLine();

		int sum = 0;
		for (int i = 0; i < n.length(); i++) {
			sum += Integer.parseInt(n.substring(i,i+1));
		}

		String result = "";
		if (sum % 9 == 0) {
			result = "Yes";
		} else {
			result = "No";
		}
		System.out.println(result);

		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.nextLine();

		int sum = 0;
		for (int i = 0; i < n.length(); i++) {
			sum += Integer.parseInt(n.substring(i,i+1));
		}

		String result = "";
		if (sum % 9 == 0) {
			result = "Yes";
		} else {
			result = "No";
		}
		System.out.println(result);

		sc.close();

	}

} Main public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String n = sc.nextLine();

		int sum = 0;
		for (int i = 0; i < n.length(); i++) {
			sum += Integer.parseInt(n.substring(i,i+1));
		}

		String result = "";
		if (sum % 9 == 0) {
			result = "Yes";
		} else {
			result = "No";
		}
		System.out.println(result);

		sc.close();

	} main {

		Scanner sc = new Scanner(System.in);
		String n = sc.nextLine();

		int sum = 0;
		for (int i = 0; i < n.length(); i++) {
			sum += Integer.parseInt(n.substring(i,i+1));
		}

		String result = "";
		if (sum % 9 == 0) {
			result = "Yes";
		} else {
			result = "No";
		}
		System.out.println(result);

		sc.close();

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String n = sc.nextLine(); n sc.nextLine() sc.nextLine sc int sum = 0; sum 0 for (int i = 0; i < n.length(); i++) {
			sum += Integer.parseInt(n.substring(i,i+1));
		} int i = 0; int i = 0; i 0 i < n.length() i n.length() n.length n i++ i++ i {
			sum += Integer.parseInt(n.substring(i,i+1));
		} {
			sum += Integer.parseInt(n.substring(i,i+1));
		} sum += Integer.parseInt(n.substring(i,i+1)) sum Integer.parseInt(n.substring(i,i+1)) Integer.parseInt Integer n.substring(i,i+1) n.substring n i i+1 i 1 String result = ""; result "" if (sum % 9 == 0) {
			result = "Yes";
		} else {
			result = "No";
		} sum % 9 == 0 sum % 9 sum 9 0 {
			result = "Yes";
		} result = "Yes" result "Yes" {
			result = "No";
		} result = "No" result "No" System.out.println(result) System.out.println System.out System System.out result 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.nextLine();

		int sum = 0;
		for (int i = 0; i < n.length(); i++) {
			sum += Integer.parseInt(n.substring(i,i+1));
		}

		String result = "";
		if (sum % 9 == 0) {
			result = "Yes";
		} else {
			result = "No";
		}
		System.out.println(result);

		sc.close();

	}

} public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String n = sc.nextLine();

		int sum = 0;
		for (int i = 0; i < n.length(); i++) {
			sum += Integer.parseInt(n.substring(i,i+1));
		}

		String result = "";
		if (sum % 9 == 0) {
			result = "Yes";
		} else {
			result = "No";
		}
		System.out.println(result);

		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.nextLine();

		int sum = 0;
		for (int i = 0; i < n.length(); i++) {
			sum += Integer.parseInt(n.substring(i,i+1));
		}

		String result = "";
		if (sum % 9 == 0) {
			result = "Yes";
		} else {
			result = "No";
		}
		System.out.println(result);

		sc.close();

	}

}
