import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    char[] nChar = sc.next().toCharArray();
    int[] n = new int[nChar.length];
    int sum = 0;
    String ans;

    for (int cnt = 0; cnt < n.length; cnt++) {
      n[cnt] = Character.getNumericValue(nChar[cnt]);
      sum += n[cnt];
    }
    if(sum % 9 == 0){
      ans = "Yes";
    }
    else{
      ans = "No";
    }

    System.out.println(ans);
    sc.close();
  }
} import java.util.Scanner; Scanner java.util public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    char[] nChar = sc.next().toCharArray();
    int[] n = new int[nChar.length];
    int sum = 0;
    String ans;

    for (int cnt = 0; cnt < n.length; cnt++) {
      n[cnt] = Character.getNumericValue(nChar[cnt]);
      sum += n[cnt];
    }
    if(sum % 9 == 0){
      ans = "Yes";
    }
    else{
      ans = "No";
    }

    System.out.println(ans);
    sc.close();
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    char[] nChar = sc.next().toCharArray();
    int[] n = new int[nChar.length];
    int sum = 0;
    String ans;

    for (int cnt = 0; cnt < n.length; cnt++) {
      n[cnt] = Character.getNumericValue(nChar[cnt]);
      sum += n[cnt];
    }
    if(sum % 9 == 0){
      ans = "Yes";
    }
    else{
      ans = "No";
    }

    System.out.println(ans);
    sc.close();
  } main {
    Scanner sc = new Scanner(System.in);
    char[] nChar = sc.next().toCharArray();
    int[] n = new int[nChar.length];
    int sum = 0;
    String ans;

    for (int cnt = 0; cnt < n.length; cnt++) {
      n[cnt] = Character.getNumericValue(nChar[cnt]);
      sum += n[cnt];
    }
    if(sum % 9 == 0){
      ans = "Yes";
    }
    else{
      ans = "No";
    }

    System.out.println(ans);
    sc.close();
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) char[] nChar = sc.next().toCharArray(); nChar sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc int[] n = new int[nChar.length]; n new int[nChar.length] nChar.length nChar nChar.length int sum = 0; sum 0 String ans; ans for (int cnt = 0; cnt < n.length; cnt++) {
      n[cnt] = Character.getNumericValue(nChar[cnt]);
      sum += n[cnt];
    } int cnt = 0; int cnt = 0; cnt 0 cnt < n.length cnt n.length n n.length cnt++ cnt++ cnt {
      n[cnt] = Character.getNumericValue(nChar[cnt]);
      sum += n[cnt];
    } {
      n[cnt] = Character.getNumericValue(nChar[cnt]);
      sum += n[cnt];
    } n[cnt] = Character.getNumericValue(nChar[cnt]) n[cnt] n cnt Character.getNumericValue(nChar[cnt]) Character.getNumericValue Character nChar[cnt] nChar cnt sum += n[cnt] sum n[cnt] n cnt if(sum % 9 == 0){
      ans = "Yes";
    }
    else{
      ans = "No";
    } sum % 9 == 0 sum % 9 sum 9 0 {
      ans = "Yes";
    } ans = "Yes" ans "Yes" {
      ans = "No";
    } ans = "No" ans "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);
    char[] nChar = sc.next().toCharArray();
    int[] n = new int[nChar.length];
    int sum = 0;
    String ans;

    for (int cnt = 0; cnt < n.length; cnt++) {
      n[cnt] = Character.getNumericValue(nChar[cnt]);
      sum += n[cnt];
    }
    if(sum % 9 == 0){
      ans = "Yes";
    }
    else{
      ans = "No";
    }

    System.out.println(ans);
    sc.close();
  }
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    char[] nChar = sc.next().toCharArray();
    int[] n = new int[nChar.length];
    int sum = 0;
    String ans;

    for (int cnt = 0; cnt < n.length; cnt++) {
      n[cnt] = Character.getNumericValue(nChar[cnt]);
      sum += n[cnt];
    }
    if(sum % 9 == 0){
      ans = "Yes";
    }
    else{
      ans = "No";
    }

    System.out.println(ans);
    sc.close();
  }
} Main
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    char[] nChar = sc.next().toCharArray();
    int[] n = new int[nChar.length];
    int sum = 0;
    String ans;

    for (int cnt = 0; cnt < n.length; cnt++) {
      n[cnt] = Character.getNumericValue(nChar[cnt]);
      sum += n[cnt];
    }
    if(sum % 9 == 0){
      ans = "Yes";
    }
    else{
      ans = "No";
    }

    System.out.println(ans);
    sc.close();
  }
}
