import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args)throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		char[] str = br.readLine().toCharArray();
		int n = 0;
		for(char c : str){
			n = (n + Integer.parseInt("" + c))%9;
		}
		
		System.out.println((n == 0) ? "Yes" : "No");
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main{
	public static void main(String[] args)throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		char[] str = br.readLine().toCharArray();
		int n = 0;
		for(char c : str){
			n = (n + Integer.parseInt("" + c))%9;
		}
		
		System.out.println((n == 0) ? "Yes" : "No");
	}
} Main public static void main(String[] args)throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		char[] str = br.readLine().toCharArray();
		int n = 0;
		for(char c : str){
			n = (n + Integer.parseInt("" + c))%9;
		}
		
		System.out.println((n == 0) ? "Yes" : "No");
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		char[] str = br.readLine().toCharArray();
		int n = 0;
		for(char c : str){
			n = (n + Integer.parseInt("" + c))%9;
		}
		
		System.out.println((n == 0) ? "Yes" : "No");
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) char[] str = br.readLine().toCharArray(); str br.readLine().toCharArray() br.readLine().toCharArray br.readLine() br.readLine br int n = 0; n 0 for(char c : str){
			n = (n + Integer.parseInt("" + c))%9;
		} char c str {
			n = (n + Integer.parseInt("" + c))%9;
		} {
			n = (n + Integer.parseInt("" + c))%9;
		} n = (n + Integer.parseInt("" + c))%9 n (n + Integer.parseInt("" + c))%9 (n + Integer.parseInt("" + c)) n Integer.parseInt("" + c) Integer.parseInt Integer "" + c "" c 9 System.out.println((n == 0) ? "Yes" : "No") System.out.println System.out System System.out (n == 0) ? "Yes" : "No" (n == 0) n 0 "Yes" "No" String[] args args public class Main{
	public static void main(String[] args)throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		char[] str = br.readLine().toCharArray();
		int n = 0;
		for(char c : str){
			n = (n + Integer.parseInt("" + c))%9;
		}
		
		System.out.println((n == 0) ? "Yes" : "No");
	}
} public class Main{
	public static void main(String[] args)throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		char[] str = br.readLine().toCharArray();
		int n = 0;
		for(char c : str){
			n = (n + Integer.parseInt("" + c))%9;
		}
		
		System.out.println((n == 0) ? "Yes" : "No");
	}
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args)throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		char[] str = br.readLine().toCharArray();
		int n = 0;
		for(char c : str){
			n = (n + Integer.parseInt("" + c))%9;
		}
		
		System.out.println((n == 0) ? "Yes" : "No");
	}
}
