import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String tmp = sc.nextLine();
		long ans   = 0;

		for(int i = 0; i < tmp.length(); i++) {
			int y = Integer.parseInt(tmp.substring(i, i + 1));
			ans += y;

		}

		String a;
		if(ans % 9 == 0) {
			a = "Yes";
		}else {
			a = "No";
		}


		System.out.println(a);

	}

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

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String tmp = sc.nextLine();
		long ans   = 0;

		for(int i = 0; i < tmp.length(); i++) {
			int y = Integer.parseInt(tmp.substring(i, i + 1));
			ans += y;

		}

		String a;
		if(ans % 9 == 0) {
			a = "Yes";
		}else {
			a = "No";
		}


		System.out.println(a);

	}

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

		Scanner sc = new Scanner(System.in);
		String tmp = sc.nextLine();
		long ans   = 0;

		for(int i = 0; i < tmp.length(); i++) {
			int y = Integer.parseInt(tmp.substring(i, i + 1));
			ans += y;

		}

		String a;
		if(ans % 9 == 0) {
			a = "Yes";
		}else {
			a = "No";
		}


		System.out.println(a);

	} main {

		Scanner sc = new Scanner(System.in);
		String tmp = sc.nextLine();
		long ans   = 0;

		for(int i = 0; i < tmp.length(); i++) {
			int y = Integer.parseInt(tmp.substring(i, i + 1));
			ans += y;

		}

		String a;
		if(ans % 9 == 0) {
			a = "Yes";
		}else {
			a = "No";
		}


		System.out.println(a);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String tmp = sc.nextLine(); tmp sc.nextLine() sc.nextLine sc long ans   = 0; ans 0 for(int i = 0; i < tmp.length(); i++) {
			int y = Integer.parseInt(tmp.substring(i, i + 1));
			ans += y;

		} int i = 0; int i = 0; i 0 i < tmp.length() i tmp.length() tmp.length tmp i++ i++ i {
			int y = Integer.parseInt(tmp.substring(i, i + 1));
			ans += y;

		} {
			int y = Integer.parseInt(tmp.substring(i, i + 1));
			ans += y;

		} int y = Integer.parseInt(tmp.substring(i, i + 1)); y Integer.parseInt(tmp.substring(i, i + 1)) Integer.parseInt Integer tmp.substring(i, i + 1) tmp.substring tmp i i + 1 i 1 ans += y ans y String a; a if(ans % 9 == 0) {
			a = "Yes";
		}else {
			a = "No";
		} ans % 9 == 0 ans % 9 ans 9 0 {
			a = "Yes";
		} a = "Yes" a "Yes" {
			a = "No";
		} a = "No" a "No" System.out.println(a) System.out.println System.out System System.out a String[] args args public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String tmp = sc.nextLine();
		long ans   = 0;

		for(int i = 0; i < tmp.length(); i++) {
			int y = Integer.parseInt(tmp.substring(i, i + 1));
			ans += y;

		}

		String a;
		if(ans % 9 == 0) {
			a = "Yes";
		}else {
			a = "No";
		}


		System.out.println(a);

	}

} public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String tmp = sc.nextLine();
		long ans   = 0;

		for(int i = 0; i < tmp.length(); i++) {
			int y = Integer.parseInt(tmp.substring(i, i + 1));
			ans += y;

		}

		String a;
		if(ans % 9 == 0) {
			a = "Yes";
		}else {
			a = "No";
		}


		System.out.println(a);

	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String tmp = sc.nextLine();
		long ans   = 0;

		for(int i = 0; i < tmp.length(); i++) {
			int y = Integer.parseInt(tmp.substring(i, i + 1));
			ans += y;

		}

		String a;
		if(ans % 9 == 0) {
			a = "Yes";
		}else {
			a = "No";
		}


		System.out.println(a);

	}

}
