import java.util.Scanner;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String N = sc.next();
    int sum = 0;
    char[] C = N.toCharArray();
    for(char c : C) {
      sum += Character.getNumericValue(c);
    }
    String ans = "No";
    if(sum % 9 == 0) ans = "Yes";
    System.out.println(ans);
  }
} import java.util.Scanner; Scanner java.util public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String N = sc.next();
    int sum = 0;
    char[] C = N.toCharArray();
    for(char c : C) {
      sum += Character.getNumericValue(c);
    }
    String ans = "No";
    if(sum % 9 == 0) ans = "Yes";
    System.out.println(ans);
  }
} Main public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String N = sc.next();
    int sum = 0;
    char[] C = N.toCharArray();
    for(char c : C) {
      sum += Character.getNumericValue(c);
    }
    String ans = "No";
    if(sum % 9 == 0) ans = "Yes";
    System.out.println(ans);
  } main {
    Scanner sc = new Scanner(System.in);
    String N = sc.next();
    int sum = 0;
    char[] C = N.toCharArray();
    for(char c : C) {
      sum += Character.getNumericValue(c);
    }
    String ans = "No";
    if(sum % 9 == 0) ans = "Yes";
    System.out.println(ans);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String N = sc.next(); N sc.next() sc.next sc int sum = 0; sum 0 char[] C = N.toCharArray(); C N.toCharArray() N.toCharArray N for(char c : C) {
      sum += Character.getNumericValue(c);
    } char c C {
      sum += Character.getNumericValue(c);
    } {
      sum += Character.getNumericValue(c);
    } sum += Character.getNumericValue(c) sum Character.getNumericValue(c) Character.getNumericValue Character c String ans = "No"; ans "No" if(sum % 9 == 0) ans = "Yes"; sum % 9 == 0 sum % 9 sum 9 0 ans = "Yes" ans "Yes" System.out.println(ans) System.out.println System.out System System.out ans String args[] args public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String N = sc.next();
    int sum = 0;
    char[] C = N.toCharArray();
    for(char c : C) {
      sum += Character.getNumericValue(c);
    }
    String ans = "No";
    if(sum % 9 == 0) ans = "Yes";
    System.out.println(ans);
  }
} public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String N = sc.next();
    int sum = 0;
    char[] C = N.toCharArray();
    for(char c : C) {
      sum += Character.getNumericValue(c);
    }
    String ans = "No";
    if(sum % 9 == 0) ans = "Yes";
    System.out.println(ans);
  }
} Main
import java.util.Scanner;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String N = sc.next();
    int sum = 0;
    char[] C = N.toCharArray();
    for(char c : C) {
      sum += Character.getNumericValue(c);
    }
    String ans = "No";
    if(sum % 9 == 0) ans = "Yes";
    System.out.println(ans);
  }
}