import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    char[] n = sc.next().toCharArray();
    int sum = 0;
    for (char nn : n) {
      sum += Character.getNumericValue(nn);
    }
    String ans = sum % 9 == 0 ? "Yes" : "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[] n = sc.next().toCharArray();
    int sum = 0;
    for (char nn : n) {
      sum += Character.getNumericValue(nn);
    }
    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);
    char[] n = sc.next().toCharArray();
    int sum = 0;
    for (char nn : n) {
      sum += Character.getNumericValue(nn);
    }
    String ans = sum % 9 == 0 ? "Yes" : "No";
    System.out.println(ans);
    sc.close();
  } main {
    Scanner sc = new Scanner(System.in);
    char[] n = sc.next().toCharArray();
    int sum = 0;
    for (char nn : n) {
      sum += Character.getNumericValue(nn);
    }
    String ans = sum % 9 == 0 ? "Yes" : "No";
    System.out.println(ans);
    sc.close();
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) char[] n = sc.next().toCharArray(); n sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc int sum = 0; sum 0 for (char nn : n) {
      sum += Character.getNumericValue(nn);
    } char nn n {
      sum += Character.getNumericValue(nn);
    } {
      sum += Character.getNumericValue(nn);
    } sum += Character.getNumericValue(nn) sum Character.getNumericValue(nn) Character.getNumericValue Character nn 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);
    char[] n = sc.next().toCharArray();
    int sum = 0;
    for (char nn : n) {
      sum += Character.getNumericValue(nn);
    }
    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);
    char[] n = sc.next().toCharArray();
    int sum = 0;
    for (char nn : n) {
      sum += Character.getNumericValue(nn);
    }
    String ans = sum % 9 == 0 ? "Yes" : "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[] n = sc.next().toCharArray();
    int sum = 0;
    for (char nn : n) {
      sum += Character.getNumericValue(nn);
    }
    String ans = sum % 9 == 0 ? "Yes" : "No";
    System.out.println(ans);
    sc.close();
  }
}
