import java.util.*;

public class Main{
public static void main(String[] args){
	Scanner scanner = new Scanner(System.in);
  	String i = scanner.next();
  	char[] chars = i.toCharArray();
  	int sum = 0;
  	for(char c : chars){
    	sum += Integer.valueOf(c+"");
    }
  	String res = sum % 9 == 0 ? "Yes" : "No";
  System.out.println(res);
}
} import java.util.*; util.* java public class Main{
public static void main(String[] args){
	Scanner scanner = new Scanner(System.in);
  	String i = scanner.next();
  	char[] chars = i.toCharArray();
  	int sum = 0;
  	for(char c : chars){
    	sum += Integer.valueOf(c+"");
    }
  	String res = sum % 9 == 0 ? "Yes" : "No";
  System.out.println(res);
}
} Main public static void main(String[] args){
	Scanner scanner = new Scanner(System.in);
  	String i = scanner.next();
  	char[] chars = i.toCharArray();
  	int sum = 0;
  	for(char c : chars){
    	sum += Integer.valueOf(c+"");
    }
  	String res = sum % 9 == 0 ? "Yes" : "No";
  System.out.println(res);
} main {
	Scanner scanner = new Scanner(System.in);
  	String i = scanner.next();
  	char[] chars = i.toCharArray();
  	int sum = 0;
  	for(char c : chars){
    	sum += Integer.valueOf(c+"");
    }
  	String res = sum % 9 == 0 ? "Yes" : "No";
  System.out.println(res);
} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String i = scanner.next(); i scanner.next() scanner.next scanner char[] chars = i.toCharArray(); chars i.toCharArray() i.toCharArray i int sum = 0; sum 0 for(char c : chars){
    	sum += Integer.valueOf(c+"");
    } char c chars {
    	sum += Integer.valueOf(c+"");
    } {
    	sum += Integer.valueOf(c+"");
    } sum += Integer.valueOf(c+"") sum Integer.valueOf(c+"") Integer.valueOf Integer c+"" c "" String res = sum % 9 == 0 ? "Yes" : "No"; res sum % 9 == 0 ? "Yes" : "No" sum % 9 == 0 sum % 9 sum 9 0 "Yes" "No" System.out.println(res) System.out.println System.out System System.out res String[] args args public class Main{
public static void main(String[] args){
	Scanner scanner = new Scanner(System.in);
  	String i = scanner.next();
  	char[] chars = i.toCharArray();
  	int sum = 0;
  	for(char c : chars){
    	sum += Integer.valueOf(c+"");
    }
  	String res = sum % 9 == 0 ? "Yes" : "No";
  System.out.println(res);
}
} public class Main{
public static void main(String[] args){
	Scanner scanner = new Scanner(System.in);
  	String i = scanner.next();
  	char[] chars = i.toCharArray();
  	int sum = 0;
  	for(char c : chars){
    	sum += Integer.valueOf(c+"");
    }
  	String res = sum % 9 == 0 ? "Yes" : "No";
  System.out.println(res);
}
} Main
import java.util.*;

public class Main{
public static void main(String[] args){
	Scanner scanner = new Scanner(System.in);
  	String i = scanner.next();
  	char[] chars = i.toCharArray();
  	int sum = 0;
  	for(char c : chars){
    	sum += Integer.valueOf(c+"");
    }
  	String res = sum % 9 == 0 ? "Yes" : "No";
  System.out.println(res);
}
}