import java.util.Scanner;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long sum = 0;
    char[] n = sc.nextLine().toCharArray();
    for (int cnt = 0; cnt < n.length; cnt++) {
      sum += Character.getNumericValue(n[cnt]);
    }
    String ans = (sum % 9 == 0) ? "Yes" : "No";
    System.out.println(ans);
    sc.close();
  }
} import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays java.util public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long sum = 0;
    char[] n = sc.nextLine().toCharArray();
    for (int cnt = 0; cnt < n.length; cnt++) {
      sum += Character.getNumericValue(n[cnt]);
    }
    String ans = (sum % 9 == 0) ? "Yes" : "No";
    System.out.println(ans);
    sc.close();
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long sum = 0;
    char[] n = sc.nextLine().toCharArray();
    for (int cnt = 0; cnt < n.length; cnt++) {
      sum += Character.getNumericValue(n[cnt]);
    }
    String ans = (sum % 9 == 0) ? "Yes" : "No";
    System.out.println(ans);
    sc.close();
  } main {
    Scanner sc = new Scanner(System.in);
    long sum = 0;
    char[] n = sc.nextLine().toCharArray();
    for (int cnt = 0; cnt < n.length; cnt++) {
      sum += Character.getNumericValue(n[cnt]);
    }
    String ans = (sum % 9 == 0) ? "Yes" : "No";
    System.out.println(ans);
    sc.close();
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long sum = 0; sum 0 char[] n = sc.nextLine().toCharArray(); n sc.nextLine().toCharArray() sc.nextLine().toCharArray sc.nextLine() sc.nextLine sc for (int cnt = 0; cnt < n.length; cnt++) {
      sum += Character.getNumericValue(n[cnt]);
    } int cnt = 0; int cnt = 0; cnt 0 cnt < n.length cnt n.length n n.length cnt++ cnt++ cnt {
      sum += Character.getNumericValue(n[cnt]);
    } {
      sum += Character.getNumericValue(n[cnt]);
    } sum += Character.getNumericValue(n[cnt]) sum Character.getNumericValue(n[cnt]) Character.getNumericValue Character n[cnt] n cnt String ans = (sum % 9 == 0) ? "Yes" : "No"; ans (sum % 9 == 0) ? "Yes" : "No" (sum % 9 == 0) sum % 9 sum 9 0 "Yes" "No" System.out.println(ans) System.out.println System.out System System.out ans sc.close() sc.close sc String[] args args public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long sum = 0;
    char[] n = sc.nextLine().toCharArray();
    for (int cnt = 0; cnt < n.length; cnt++) {
      sum += Character.getNumericValue(n[cnt]);
    }
    String ans = (sum % 9 == 0) ? "Yes" : "No";
    System.out.println(ans);
    sc.close();
  }
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long sum = 0;
    char[] n = sc.nextLine().toCharArray();
    for (int cnt = 0; cnt < n.length; cnt++) {
      sum += Character.getNumericValue(n[cnt]);
    }
    String ans = (sum % 9 == 0) ? "Yes" : "No";
    System.out.println(ans);
    sc.close();
  }
} Main
import java.util.Scanner;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long sum = 0;
    char[] n = sc.nextLine().toCharArray();
    for (int cnt = 0; cnt < n.length; cnt++) {
      sum += Character.getNumericValue(n[cnt]);
    }
    String ans = (sum % 9 == 0) ? "Yes" : "No";
    System.out.println(ans);
    sc.close();
  }
}