import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// AtCoder_B
		Scanner sc = new Scanner(System.in);
		String N = sc.nextLine();

		int ans = 0;
		int iN = 0;
		for(int i=0; i<N.length(); i++) {
			iN = Integer.parseInt(String.valueOf(N.charAt(i)));
			ans = (ans+ iN)%9;
		}

		if(ans == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	    // Scannerクラスのインスタンスをクローズ
		sc.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		// AtCoder_B
		Scanner sc = new Scanner(System.in);
		String N = sc.nextLine();

		int ans = 0;
		int iN = 0;
		for(int i=0; i<N.length(); i++) {
			iN = Integer.parseInt(String.valueOf(N.charAt(i)));
			ans = (ans+ iN)%9;
		}

		if(ans == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	    // Scannerクラスのインスタンスをクローズ
		sc.close();
	}
} Main public static void main(String[] args) {
		// AtCoder_B
		Scanner sc = new Scanner(System.in);
		String N = sc.nextLine();

		int ans = 0;
		int iN = 0;
		for(int i=0; i<N.length(); i++) {
			iN = Integer.parseInt(String.valueOf(N.charAt(i)));
			ans = (ans+ iN)%9;
		}

		if(ans == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	    // Scannerクラスのインスタンスをクローズ
		sc.close();
	} main {
		// AtCoder_B
		Scanner sc = new Scanner(System.in);
		String N = sc.nextLine();

		int ans = 0;
		int iN = 0;
		for(int i=0; i<N.length(); i++) {
			iN = Integer.parseInt(String.valueOf(N.charAt(i)));
			ans = (ans+ iN)%9;
		}

		if(ans == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	    // Scannerクラスのインスタンスをクローズ
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String N = sc.nextLine(); N sc.nextLine() sc.nextLine sc int ans = 0; ans 0 int iN = 0; iN 0 for(int i=0; i<N.length(); i++) {
			iN = Integer.parseInt(String.valueOf(N.charAt(i)));
			ans = (ans+ iN)%9;
		} int i=0; int i=0; i 0 i<N.length() i N.length() N.length N i++ i++ i {
			iN = Integer.parseInt(String.valueOf(N.charAt(i)));
			ans = (ans+ iN)%9;
		} {
			iN = Integer.parseInt(String.valueOf(N.charAt(i)));
			ans = (ans+ iN)%9;
		} iN = Integer.parseInt(String.valueOf(N.charAt(i))) iN Integer.parseInt(String.valueOf(N.charAt(i))) Integer.parseInt Integer String.valueOf(N.charAt(i)) String.valueOf String N.charAt(i) N.charAt N i ans = (ans+ iN)%9 ans (ans+ iN)%9 (ans+ iN) ans iN 9 if(ans == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		} ans == 0 ans 0 {
			System.out.println("Yes");
		} System.out.println("Yes") System.out.println System.out System System.out "Yes" {
			System.out.println("No");
		} System.out.println("No") System.out.println System.out System System.out "No" sc.close() sc.close sc String[] args args public class Main {

	public static void main(String[] args) {
		// AtCoder_B
		Scanner sc = new Scanner(System.in);
		String N = sc.nextLine();

		int ans = 0;
		int iN = 0;
		for(int i=0; i<N.length(); i++) {
			iN = Integer.parseInt(String.valueOf(N.charAt(i)));
			ans = (ans+ iN)%9;
		}

		if(ans == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	    // Scannerクラスのインスタンスをクローズ
		sc.close();
	}
} public class Main {

	public static void main(String[] args) {
		// AtCoder_B
		Scanner sc = new Scanner(System.in);
		String N = sc.nextLine();

		int ans = 0;
		int iN = 0;
		for(int i=0; i<N.length(); i++) {
			iN = Integer.parseInt(String.valueOf(N.charAt(i)));
			ans = (ans+ iN)%9;
		}

		if(ans == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	    // Scannerクラスのインスタンスをクローズ
		sc.close();
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// AtCoder_B
		Scanner sc = new Scanner(System.in);
		String N = sc.nextLine();

		int ans = 0;
		int iN = 0;
		for(int i=0; i<N.length(); i++) {
			iN = Integer.parseInt(String.valueOf(N.charAt(i)));
			ans = (ans+ iN)%9;
		}

		if(ans == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	    // Scannerクラスのインスタンスをクローズ
		sc.close();
	}
}
