import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		sc.close();
		int l = N.length();
		int ans = 0;
		for(int i=0;i<l;++i){
			ans += N.charAt(i) - '0';
		}
		if(ans%9==0){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}

	}
}
 import java.util.*; util.* java class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		sc.close();
		int l = N.length();
		int ans = 0;
		for(int i=0;i<l;++i){
			ans += N.charAt(i) - '0';
		}
		if(ans%9==0){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}

	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		sc.close();
		int l = N.length();
		int ans = 0;
		for(int i=0;i<l;++i){
			ans += N.charAt(i) - '0';
		}
		if(ans%9==0){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}

	} main {
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		sc.close();
		int l = N.length();
		int ans = 0;
		for(int i=0;i<l;++i){
			ans += N.charAt(i) - '0';
		}
		if(ans%9==0){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String N = sc.next(); N sc.next() sc.next sc sc.close() sc.close sc int l = N.length(); l N.length() N.length N int ans = 0; ans 0 for(int i=0;i<l;++i){
			ans += N.charAt(i) - '0';
		} int i=0; int i=0; i 0 i<l i l ++i ++i i {
			ans += N.charAt(i) - '0';
		} {
			ans += N.charAt(i) - '0';
		} ans += N.charAt(i) - '0' ans N.charAt(i) - '0' N.charAt(i) N.charAt N i '0' if(ans%9==0){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		} ans%9==0 ans%9 ans 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
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		sc.close();
		int l = N.length();
		int ans = 0;
		for(int i=0;i<l;++i){
			ans += N.charAt(i) - '0';
		}
		if(ans%9==0){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}

	}
}

