import java.util.Scanner;
public class Main {
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    String n = scan.nextLine();
    int len = n.length();
    int sum=0;
    char[] arr = new char[len];
    
    for(int i=0;i<len;i++){
      arr[i] = (n.charAt(i));
    }
    for(int i=0;i<len;i++){
      sum = sum + Character.getNumericValue(arr[i]);
    }
    if(sum%9 == 0 || n.equals("0")){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
  
} import java.util.Scanner; Scanner java.util public class Main {
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    String n = scan.nextLine();
    int len = n.length();
    int sum=0;
    char[] arr = new char[len];
    
    for(int i=0;i<len;i++){
      arr[i] = (n.charAt(i));
    }
    for(int i=0;i<len;i++){
      sum = sum + Character.getNumericValue(arr[i]);
    }
    if(sum%9 == 0 || n.equals("0")){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
  
} Main public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    String n = scan.nextLine();
    int len = n.length();
    int sum=0;
    char[] arr = new char[len];
    
    for(int i=0;i<len;i++){
      arr[i] = (n.charAt(i));
    }
    for(int i=0;i<len;i++){
      sum = sum + Character.getNumericValue(arr[i]);
    }
    if(sum%9 == 0 || n.equals("0")){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  } main {
    Scanner scan = new Scanner(System.in);
    String n = scan.nextLine();
    int len = n.length();
    int sum=0;
    char[] arr = new char[len];
    
    for(int i=0;i<len;i++){
      arr[i] = (n.charAt(i));
    }
    for(int i=0;i<len;i++){
      sum = sum + Character.getNumericValue(arr[i]);
    }
    if(sum%9 == 0 || n.equals("0")){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String n = scan.nextLine(); n scan.nextLine() scan.nextLine scan int len = n.length(); len n.length() n.length n int sum=0; sum 0 char[] arr = new char[len]; arr new char[len] len for(int i=0;i<len;i++){
      arr[i] = (n.charAt(i));
    } int i=0; int i=0; i 0 i<len i len i++ i++ i {
      arr[i] = (n.charAt(i));
    } {
      arr[i] = (n.charAt(i));
    } arr[i] = (n.charAt(i)) arr[i] arr i (n.charAt(i)) n.charAt n i for(int i=0;i<len;i++){
      sum = sum + Character.getNumericValue(arr[i]);
    } int i=0; int i=0; i 0 i<len i len i++ i++ i {
      sum = sum + Character.getNumericValue(arr[i]);
    } {
      sum = sum + Character.getNumericValue(arr[i]);
    } sum = sum + Character.getNumericValue(arr[i]) sum sum + Character.getNumericValue(arr[i]) sum Character.getNumericValue(arr[i]) Character.getNumericValue Character arr[i] arr i if(sum%9 == 0 || n.equals("0")){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    } sum%9 == 0 || n.equals("0") sum%9 == 0 sum%9 sum 9 0 n.equals("0") n.equals n "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 {
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    String n = scan.nextLine();
    int len = n.length();
    int sum=0;
    char[] arr = new char[len];
    
    for(int i=0;i<len;i++){
      arr[i] = (n.charAt(i));
    }
    for(int i=0;i<len;i++){
      sum = sum + Character.getNumericValue(arr[i]);
    }
    if(sum%9 == 0 || n.equals("0")){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
  
} public class Main {
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    String n = scan.nextLine();
    int len = n.length();
    int sum=0;
    char[] arr = new char[len];
    
    for(int i=0;i<len;i++){
      arr[i] = (n.charAt(i));
    }
    for(int i=0;i<len;i++){
      sum = sum + Character.getNumericValue(arr[i]);
    }
    if(sum%9 == 0 || n.equals("0")){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
  
} Main
import java.util.Scanner;
public class Main {
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    String n = scan.nextLine();
    int len = n.length();
    int sum=0;
    char[] arr = new char[len];
    
    for(int i=0;i<len;i++){
      arr[i] = (n.charAt(i));
    }
    for(int i=0;i<len;i++){
      sum = sum + Character.getNumericValue(arr[i]);
    }
    if(sum%9 == 0 || n.equals("0")){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
  
}