//package atcoder.beginnercontest.r176;

import java.util.Scanner;

/**
 * @author pribic (Priyank Doshi)
 * @since 29/08/20
 */
public class Main {

  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      String n = sc.next();
      int sum = 0;

      for (char c : n.toCharArray())
        sum += (c - '0');
      System.out.println(sum % 9 == 0 ? "Yes" : "No");
    }
  }
} import java.util.Scanner; Scanner java.util public class Main {

  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      String n = sc.next();
      int sum = 0;

      for (char c : n.toCharArray())
        sum += (c - '0');
      System.out.println(sum % 9 == 0 ? "Yes" : "No");
    }
  }
} Main public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      String n = sc.next();
      int sum = 0;

      for (char c : n.toCharArray())
        sum += (c - '0');
      System.out.println(sum % 9 == 0 ? "Yes" : "No");
    }
  } main {
    try (Scanner sc = new Scanner(System.in)) {
      String n = sc.next();
      int sum = 0;

      for (char c : n.toCharArray())
        sum += (c - '0');
      System.out.println(sum % 9 == 0 ? "Yes" : "No");
    }
  } try (Scanner sc = new Scanner(System.in)) {
      String n = sc.next();
      int sum = 0;

      for (char c : n.toCharArray())
        sum += (c - '0');
      System.out.println(sum % 9 == 0 ? "Yes" : "No");
    } {
      String n = sc.next();
      int sum = 0;

      for (char c : n.toCharArray())
        sum += (c - '0');
      System.out.println(sum % 9 == 0 ? "Yes" : "No");
    } Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) String n = sc.next(); n sc.next() sc.next sc int sum = 0; sum 0 for (char c : n.toCharArray())
        sum += (c - '0'); char c n.toCharArray() n.toCharArray n sum += (c - '0'); sum += (c - '0') sum (c - '0') c '0' System.out.println(sum % 9 == 0 ? "Yes" : "No") System.out.println System.out System System.out sum % 9 == 0 ? "Yes" : "No" sum % 9 == 0 sum % 9 sum 9 0 "Yes" "No" String[] args args public class Main {

  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      String n = sc.next();
      int sum = 0;

      for (char c : n.toCharArray())
        sum += (c - '0');
      System.out.println(sum % 9 == 0 ? "Yes" : "No");
    }
  }
} public class Main {

  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      String n = sc.next();
      int sum = 0;

      for (char c : n.toCharArray())
        sum += (c - '0');
      System.out.println(sum % 9 == 0 ? "Yes" : "No");
    }
  }
} Main
//package atcoder.beginnercontest.r176;

import java.util.Scanner;

/**
 * @author pribic (Priyank Doshi)
 * @since 29/08/20
 */
public class Main {

  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      String n = sc.next();
      int sum = 0;

      for (char c : n.toCharArray())
        sum += (c - '0');
      System.out.println(sum % 9 == 0 ? "Yes" : "No");
    }
  }
}