import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    String N = sc.nextLine();
    
    int num = 0;
    
    for(int i = 0; i < N.length(); ++i) {
      num += Character.getNumericValue(N.charAt(i));
    }
    
    System.out.println(num % 9 == 0 ? "Yes" : "No");
  }
} import java.util.*; util.* java public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    String N = sc.nextLine();
    
    int num = 0;
    
    for(int i = 0; i < N.length(); ++i) {
      num += Character.getNumericValue(N.charAt(i));
    }
    
    System.out.println(num % 9 == 0 ? "Yes" : "No");
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    String N = sc.nextLine();
    
    int num = 0;
    
    for(int i = 0; i < N.length(); ++i) {
      num += Character.getNumericValue(N.charAt(i));
    }
    
    System.out.println(num % 9 == 0 ? "Yes" : "No");
  } main {
    Scanner sc = new Scanner(System.in);
    
    String N = sc.nextLine();
    
    int num = 0;
    
    for(int i = 0; i < N.length(); ++i) {
      num += Character.getNumericValue(N.charAt(i));
    }
    
    System.out.println(num % 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 int num = 0; num 0 for(int i = 0; i < N.length(); ++i) {
      num += Character.getNumericValue(N.charAt(i));
    } int i = 0; int i = 0; i 0 i < N.length() i N.length() N.length N ++i ++i i {
      num += Character.getNumericValue(N.charAt(i));
    } {
      num += Character.getNumericValue(N.charAt(i));
    } num += Character.getNumericValue(N.charAt(i)) num Character.getNumericValue(N.charAt(i)) Character.getNumericValue Character N.charAt(i) N.charAt N i System.out.println(num % 9 == 0 ? "Yes" : "No") System.out.println System.out System System.out num % 9 == 0 ? "Yes" : "No" num % 9 == 0 num % 9 num 9 0 "Yes" "No" String[] args args public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    String N = sc.nextLine();
    
    int num = 0;
    
    for(int i = 0; i < N.length(); ++i) {
      num += Character.getNumericValue(N.charAt(i));
    }
    
    System.out.println(num % 9 == 0 ? "Yes" : "No");
  }
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    String N = sc.nextLine();
    
    int num = 0;
    
    for(int i = 0; i < N.length(); ++i) {
      num += Character.getNumericValue(N.charAt(i));
    }
    
    System.out.println(num % 9 == 0 ? "Yes" : "No");
  }
} Main
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    String N = sc.nextLine();
    
    int num = 0;
    
    for(int i = 0; i < N.length(); ++i) {
      num += Character.getNumericValue(N.charAt(i));
    }
    
    System.out.println(num % 9 == 0 ? "Yes" : "No");
  }
}