import java.util.*;
public class Main {

	
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		String n =sc.nextLine();
		n.trim();
		int sum=0;
		char line[] = n.toCharArray();
		for(int c : line)
			sum+=c-'0';
		System.out.println(sum%9==0?"Yes":"No");
	}

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

	
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		String n =sc.nextLine();
		n.trim();
		int sum=0;
		char line[] = n.toCharArray();
		for(int c : line)
			sum+=c-'0';
		System.out.println(sum%9==0?"Yes":"No");
	}

} Main public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		String n =sc.nextLine();
		n.trim();
		int sum=0;
		char line[] = n.toCharArray();
		for(int c : line)
			sum+=c-'0';
		System.out.println(sum%9==0?"Yes":"No");
	} main {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		String n =sc.nextLine();
		n.trim();
		int sum=0;
		char line[] = n.toCharArray();
		for(int c : line)
			sum+=c-'0';
		System.out.println(sum%9==0?"Yes":"No");
	} Scanner sc=new Scanner(System.in); sc new Scanner(System.in) String n =sc.nextLine(); n sc.nextLine() sc.nextLine sc n.trim() n.trim n int sum=0; sum 0 char line[] = n.toCharArray(); line n.toCharArray() n.toCharArray n for(int c : line)
			sum+=c-'0'; int c line sum+=c-'0'; sum+=c-'0' sum c-'0' c '0' System.out.println(sum%9==0?"Yes":"No") System.out.println System.out System System.out sum%9==0?"Yes":"No" sum%9==0 sum%9 sum 9 0 "Yes" "No" String[] args args public class Main {

	
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		String n =sc.nextLine();
		n.trim();
		int sum=0;
		char line[] = n.toCharArray();
		for(int c : line)
			sum+=c-'0';
		System.out.println(sum%9==0?"Yes":"No");
	}

} public class Main {

	
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		String n =sc.nextLine();
		n.trim();
		int sum=0;
		char line[] = n.toCharArray();
		for(int c : line)
			sum+=c-'0';
		System.out.println(sum%9==0?"Yes":"No");
	}

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

	
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		String n =sc.nextLine();
		n.trim();
		int sum=0;
		char line[] = n.toCharArray();
		for(int c : line)
			sum+=c-'0';
		System.out.println(sum%9==0?"Yes":"No");
	}

}
