import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

		String s = scan.next();

		char[] a = s.toCharArray();
		int total = 0;

		for(int i=0;i<a.length;i++) {
			total += Character.getNumericValue(a[i]);
		}

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

	}

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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

		String s = scan.next();

		char[] a = s.toCharArray();
		int total = 0;

		for(int i=0;i<a.length;i++) {
			total += Character.getNumericValue(a[i]);
		}

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

	}

} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

		String s = scan.next();

		char[] a = s.toCharArray();
		int total = 0;

		for(int i=0;i<a.length;i++) {
			total += Character.getNumericValue(a[i]);
		}

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

	} main {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

		String s = scan.next();

		char[] a = s.toCharArray();
		int total = 0;

		for(int i=0;i<a.length;i++) {
			total += Character.getNumericValue(a[i]);
		}

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

	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String s = scan.next(); s scan.next() scan.next scan char[] a = s.toCharArray(); a s.toCharArray() s.toCharArray s int total = 0; total 0 for(int i=0;i<a.length;i++) {
			total += Character.getNumericValue(a[i]);
		} int i=0; int i=0; i 0 i<a.length i a.length a a.length i++ i++ i {
			total += Character.getNumericValue(a[i]);
		} {
			total += Character.getNumericValue(a[i]);
		} total += Character.getNumericValue(a[i]) total Character.getNumericValue(a[i]) Character.getNumericValue Character a[i] a i if(total%9==0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		} total%9==0 total%9 total 9 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" String[] args args public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

		String s = scan.next();

		char[] a = s.toCharArray();
		int total = 0;

		for(int i=0;i<a.length;i++) {
			total += Character.getNumericValue(a[i]);
		}

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

	}

} public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

		String s = scan.next();

		char[] a = s.toCharArray();
		int total = 0;

		for(int i=0;i<a.length;i++) {
			total += Character.getNumericValue(a[i]);
		}

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

	}

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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

		String s = scan.next();

		char[] a = s.toCharArray();
		int total = 0;

		for(int i=0;i<a.length;i++) {
			total += Character.getNumericValue(a[i]);
		}

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

	}

}
