import java.util.*;

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

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