import java.util.Scanner;

public class Main {
	static String N;

	public static void main(String args[]) {
		try (Scanner sc = new Scanner(System.in)) {
			N = sc.next();
		}
		long summary=0;
		for(int i=0;i<N.length();i++) {
			summary += Long.parseLong(N.substring(i,i+1));
		}
			
		if (summary%9==0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	static String N;

	public static void main(String args[]) {
		try (Scanner sc = new Scanner(System.in)) {
			N = sc.next();
		}
		long summary=0;
		for(int i=0;i<N.length();i++) {
			summary += Long.parseLong(N.substring(i,i+1));
		}
			
		if (summary%9==0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
} Main static String N; N public static void main(String args[]) {
		try (Scanner sc = new Scanner(System.in)) {
			N = sc.next();
		}
		long summary=0;
		for(int i=0;i<N.length();i++) {
			summary += Long.parseLong(N.substring(i,i+1));
		}
			
		if (summary%9==0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	} main {
		try (Scanner sc = new Scanner(System.in)) {
			N = sc.next();
		}
		long summary=0;
		for(int i=0;i<N.length();i++) {
			summary += Long.parseLong(N.substring(i,i+1));
		}
			
		if (summary%9==0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	} try (Scanner sc = new Scanner(System.in)) {
			N = sc.next();
		} {
			N = sc.next();
		} Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) N = sc.next() N sc.next() sc.next sc long summary=0; summary 0 for(int i=0;i<N.length();i++) {
			summary += Long.parseLong(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 {
			summary += Long.parseLong(N.substring(i,i+1));
		} {
			summary += Long.parseLong(N.substring(i,i+1));
		} summary += Long.parseLong(N.substring(i,i+1)) summary Long.parseLong(N.substring(i,i+1)) Long.parseLong Long N.substring(i,i+1) N.substring N i i+1 i 1 if (summary%9==0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		} summary%9==0 summary%9 summary 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 {
	static String N;

	public static void main(String args[]) {
		try (Scanner sc = new Scanner(System.in)) {
			N = sc.next();
		}
		long summary=0;
		for(int i=0;i<N.length();i++) {
			summary += Long.parseLong(N.substring(i,i+1));
		}
			
		if (summary%9==0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
} public class Main {
	static String N;

	public static void main(String args[]) {
		try (Scanner sc = new Scanner(System.in)) {
			N = sc.next();
		}
		long summary=0;
		for(int i=0;i<N.length();i++) {
			summary += Long.parseLong(N.substring(i,i+1));
		}
			
		if (summary%9==0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
} Main
import java.util.Scanner;

public class Main {
	static String N;

	public static void main(String args[]) {
		try (Scanner sc = new Scanner(System.in)) {
			N = sc.next();
		}
		long summary=0;
		for(int i=0;i<N.length();i++) {
			summary += Long.parseLong(N.substring(i,i+1));
		}
			
		if (summary%9==0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}
