import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    // abc176_a();
    abc176_b();
  }

  private static void abc176_a() {
    try (Scanner sc = new Scanner(System.in)) {
      double nAll = sc.nextInt();
      double xOneTime = sc.nextInt();
      int tMinute = sc.nextInt();

      System.out.println((int) Math.ceil(nAll / xOneTime) * tMinute);

    } catch (Exception e) {
      System.out.println("エラー" + e);
    }
  }

  private static void abc176_b() {
    try (Scanner sc = new Scanner(System.in)) {
      String nValue = sc.next();
      ArrayList<Integer> numList = new ArrayList<Integer>();

      for (int i = 1; i <= nValue.length(); i++) {
        numList.add(parseI(nValue.substring(i - 1, i)));
      }

      int sum = 0;

      for (int num : numList) {
        sum += num;
      }

      if (sum % 9 == 0) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }

    } catch (Exception e) {
      System.out.println("エラー" + e);
    }
  }

  // int 2147483648 [ 2 * 10(9)]
  // long 9223372036854775808 [ 9 * 10(18)]

  public static int parseI(String value) {
    return Integer.parseInt(value);
  }

  public static long parseL(String value) {
    return Long.parseLong(value);
  }

  public static double parseD(String value) {
    return Double.parseDouble(value);
  }

  public static <T> String parseS(T value) {
    return String.valueOf(value);
  }

  public static BigDecimal parseBigD(String value) {
    return new BigDecimal(value);
  }

  public static BigInteger parseBigI(String value) {
    return new BigInteger(value);
  }

} import java.math.BigDecimal; BigDecimal java.math import java.math.BigInteger; BigInteger java.math import java.util.ArrayList; ArrayList java.util import java.util.Scanner; Scanner java.util public class Main {

  public static void main(String[] args) {
    // abc176_a();
    abc176_b();
  }

  private static void abc176_a() {
    try (Scanner sc = new Scanner(System.in)) {
      double nAll = sc.nextInt();
      double xOneTime = sc.nextInt();
      int tMinute = sc.nextInt();

      System.out.println((int) Math.ceil(nAll / xOneTime) * tMinute);

    } catch (Exception e) {
      System.out.println("エラー" + e);
    }
  }

  private static void abc176_b() {
    try (Scanner sc = new Scanner(System.in)) {
      String nValue = sc.next();
      ArrayList<Integer> numList = new ArrayList<Integer>();

      for (int i = 1; i <= nValue.length(); i++) {
        numList.add(parseI(nValue.substring(i - 1, i)));
      }

      int sum = 0;

      for (int num : numList) {
        sum += num;
      }

      if (sum % 9 == 0) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }

    } catch (Exception e) {
      System.out.println("エラー" + e);
    }
  }

  // int 2147483648 [ 2 * 10(9)]
  // long 9223372036854775808 [ 9 * 10(18)]

  public static int parseI(String value) {
    return Integer.parseInt(value);
  }

  public static long parseL(String value) {
    return Long.parseLong(value);
  }

  public static double parseD(String value) {
    return Double.parseDouble(value);
  }

  public static <T> String parseS(T value) {
    return String.valueOf(value);
  }

  public static BigDecimal parseBigD(String value) {
    return new BigDecimal(value);
  }

  public static BigInteger parseBigI(String value) {
    return new BigInteger(value);
  }

} Main public static void main(String[] args) {
    // abc176_a();
    abc176_b();
  } main {
    // abc176_a();
    abc176_b();
  } abc176_b() abc176_b String[] args args private static void abc176_a() {
    try (Scanner sc = new Scanner(System.in)) {
      double nAll = sc.nextInt();
      double xOneTime = sc.nextInt();
      int tMinute = sc.nextInt();

      System.out.println((int) Math.ceil(nAll / xOneTime) * tMinute);

    } catch (Exception e) {
      System.out.println("エラー" + e);
    }
  } abc176_a {
    try (Scanner sc = new Scanner(System.in)) {
      double nAll = sc.nextInt();
      double xOneTime = sc.nextInt();
      int tMinute = sc.nextInt();

      System.out.println((int) Math.ceil(nAll / xOneTime) * tMinute);

    } catch (Exception e) {
      System.out.println("エラー" + e);
    }
  } try (Scanner sc = new Scanner(System.in)) {
      double nAll = sc.nextInt();
      double xOneTime = sc.nextInt();
      int tMinute = sc.nextInt();

      System.out.println((int) Math.ceil(nAll / xOneTime) * tMinute);

    } catch (Exception e) {
      System.out.println("エラー" + e);
    } catch (Exception e) {
      System.out.println("エラー" + e);
    } Exception e {
      System.out.println("エラー" + e);
    } System.out.println("エラー" + e) System.out.println System.out System System.out "エラー" + e "エラー" e {
      double nAll = sc.nextInt();
      double xOneTime = sc.nextInt();
      int tMinute = sc.nextInt();

      System.out.println((int) Math.ceil(nAll / xOneTime) * tMinute);

    } Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) double nAll = sc.nextInt(); nAll sc.nextInt() sc.nextInt sc double xOneTime = sc.nextInt(); xOneTime sc.nextInt() sc.nextInt sc int tMinute = sc.nextInt(); tMinute sc.nextInt() sc.nextInt sc System.out.println((int) Math.ceil(nAll / xOneTime) * tMinute) System.out.println System.out System System.out (int) Math.ceil(nAll / xOneTime) * tMinute (int) Math.ceil(nAll / xOneTime) Math.ceil Math nAll / xOneTime nAll xOneTime tMinute private static void abc176_b() {
    try (Scanner sc = new Scanner(System.in)) {
      String nValue = sc.next();
      ArrayList<Integer> numList = new ArrayList<Integer>();

      for (int i = 1; i <= nValue.length(); i++) {
        numList.add(parseI(nValue.substring(i - 1, i)));
      }

      int sum = 0;

      for (int num : numList) {
        sum += num;
      }

      if (sum % 9 == 0) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }

    } catch (Exception e) {
      System.out.println("エラー" + e);
    }
  } abc176_b {
    try (Scanner sc = new Scanner(System.in)) {
      String nValue = sc.next();
      ArrayList<Integer> numList = new ArrayList<Integer>();

      for (int i = 1; i <= nValue.length(); i++) {
        numList.add(parseI(nValue.substring(i - 1, i)));
      }

      int sum = 0;

      for (int num : numList) {
        sum += num;
      }

      if (sum % 9 == 0) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }

    } catch (Exception e) {
      System.out.println("エラー" + e);
    }
  } try (Scanner sc = new Scanner(System.in)) {
      String nValue = sc.next();
      ArrayList<Integer> numList = new ArrayList<Integer>();

      for (int i = 1; i <= nValue.length(); i++) {
        numList.add(parseI(nValue.substring(i - 1, i)));
      }

      int sum = 0;

      for (int num : numList) {
        sum += num;
      }

      if (sum % 9 == 0) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }

    } catch (Exception e) {
      System.out.println("エラー" + e);
    } catch (Exception e) {
      System.out.println("エラー" + e);
    } Exception e {
      System.out.println("エラー" + e);
    } System.out.println("エラー" + e) System.out.println System.out System System.out "エラー" + e "エラー" e {
      String nValue = sc.next();
      ArrayList<Integer> numList = new ArrayList<Integer>();

      for (int i = 1; i <= nValue.length(); i++) {
        numList.add(parseI(nValue.substring(i - 1, i)));
      }

      int sum = 0;

      for (int num : numList) {
        sum += num;
      }

      if (sum % 9 == 0) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }

    } Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) String nValue = sc.next(); nValue sc.next() sc.next sc ArrayList<Integer> numList = new ArrayList<Integer>(); numList new ArrayList<Integer>() for (int i = 1; i <= nValue.length(); i++) {
        numList.add(parseI(nValue.substring(i - 1, i)));
      } int i = 1; int i = 1; i 1 i <= nValue.length() i nValue.length() nValue.length nValue i++ i++ i {
        numList.add(parseI(nValue.substring(i - 1, i)));
      } {
        numList.add(parseI(nValue.substring(i - 1, i)));
      } numList.add(parseI(nValue.substring(i - 1, i))) numList.add numList parseI(nValue.substring(i - 1, i)) parseI nValue.substring(i - 1, i) nValue.substring nValue i - 1 i 1 i int sum = 0; sum 0 for (int num : numList) {
        sum += num;
      } int num numList {
        sum += num;
      } {
        sum += num;
      } sum += num sum num if (sum % 9 == 0) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      } sum % 9 == 0 sum % 9 sum 9 0 {
        System.out.println("Yes");
      } System.out.println("Yes") System.out.println System.out System System.out "Yes" {
        System.out.println("No");
      } System.out.println("No") System.out.println System.out System System.out "No" public static int parseI(String value) {
    return Integer.parseInt(value);
  } parseI {
    return Integer.parseInt(value);
  } return Integer.parseInt(value); Integer.parseInt(value) Integer.parseInt Integer value String value value public static long parseL(String value) {
    return Long.parseLong(value);
  } parseL {
    return Long.parseLong(value);
  } return Long.parseLong(value); Long.parseLong(value) Long.parseLong Long value String value value public static double parseD(String value) {
    return Double.parseDouble(value);
  } parseD {
    return Double.parseDouble(value);
  } return Double.parseDouble(value); Double.parseDouble(value) Double.parseDouble Double value String value value public static <T> String parseS(T value) {
    return String.valueOf(value);
  } parseS {
    return String.valueOf(value);
  } return String.valueOf(value); String.valueOf(value) String.valueOf String value T value value public static BigDecimal parseBigD(String value) {
    return new BigDecimal(value);
  } parseBigD {
    return new BigDecimal(value);
  } return new BigDecimal(value); new BigDecimal(value) String value value public static BigInteger parseBigI(String value) {
    return new BigInteger(value);
  } parseBigI {
    return new BigInteger(value);
  } return new BigInteger(value); new BigInteger(value) String value value public class Main {

  public static void main(String[] args) {
    // abc176_a();
    abc176_b();
  }

  private static void abc176_a() {
    try (Scanner sc = new Scanner(System.in)) {
      double nAll = sc.nextInt();
      double xOneTime = sc.nextInt();
      int tMinute = sc.nextInt();

      System.out.println((int) Math.ceil(nAll / xOneTime) * tMinute);

    } catch (Exception e) {
      System.out.println("エラー" + e);
    }
  }

  private static void abc176_b() {
    try (Scanner sc = new Scanner(System.in)) {
      String nValue = sc.next();
      ArrayList<Integer> numList = new ArrayList<Integer>();

      for (int i = 1; i <= nValue.length(); i++) {
        numList.add(parseI(nValue.substring(i - 1, i)));
      }

      int sum = 0;

      for (int num : numList) {
        sum += num;
      }

      if (sum % 9 == 0) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }

    } catch (Exception e) {
      System.out.println("エラー" + e);
    }
  }

  // int 2147483648 [ 2 * 10(9)]
  // long 9223372036854775808 [ 9 * 10(18)]

  public static int parseI(String value) {
    return Integer.parseInt(value);
  }

  public static long parseL(String value) {
    return Long.parseLong(value);
  }

  public static double parseD(String value) {
    return Double.parseDouble(value);
  }

  public static <T> String parseS(T value) {
    return String.valueOf(value);
  }

  public static BigDecimal parseBigD(String value) {
    return new BigDecimal(value);
  }

  public static BigInteger parseBigI(String value) {
    return new BigInteger(value);
  }

} public class Main {

  public static void main(String[] args) {
    // abc176_a();
    abc176_b();
  }

  private static void abc176_a() {
    try (Scanner sc = new Scanner(System.in)) {
      double nAll = sc.nextInt();
      double xOneTime = sc.nextInt();
      int tMinute = sc.nextInt();

      System.out.println((int) Math.ceil(nAll / xOneTime) * tMinute);

    } catch (Exception e) {
      System.out.println("エラー" + e);
    }
  }

  private static void abc176_b() {
    try (Scanner sc = new Scanner(System.in)) {
      String nValue = sc.next();
      ArrayList<Integer> numList = new ArrayList<Integer>();

      for (int i = 1; i <= nValue.length(); i++) {
        numList.add(parseI(nValue.substring(i - 1, i)));
      }

      int sum = 0;

      for (int num : numList) {
        sum += num;
      }

      if (sum % 9 == 0) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }

    } catch (Exception e) {
      System.out.println("エラー" + e);
    }
  }

  // int 2147483648 [ 2 * 10(9)]
  // long 9223372036854775808 [ 9 * 10(18)]

  public static int parseI(String value) {
    return Integer.parseInt(value);
  }

  public static long parseL(String value) {
    return Long.parseLong(value);
  }

  public static double parseD(String value) {
    return Double.parseDouble(value);
  }

  public static <T> String parseS(T value) {
    return String.valueOf(value);
  }

  public static BigDecimal parseBigD(String value) {
    return new BigDecimal(value);
  }

  public static BigInteger parseBigI(String value) {
    return new BigInteger(value);
  }

} Main
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    // abc176_a();
    abc176_b();
  }

  private static void abc176_a() {
    try (Scanner sc = new Scanner(System.in)) {
      double nAll = sc.nextInt();
      double xOneTime = sc.nextInt();
      int tMinute = sc.nextInt();

      System.out.println((int) Math.ceil(nAll / xOneTime) * tMinute);

    } catch (Exception e) {
      System.out.println("エラー" + e);
    }
  }

  private static void abc176_b() {
    try (Scanner sc = new Scanner(System.in)) {
      String nValue = sc.next();
      ArrayList<Integer> numList = new ArrayList<Integer>();

      for (int i = 1; i <= nValue.length(); i++) {
        numList.add(parseI(nValue.substring(i - 1, i)));
      }

      int sum = 0;

      for (int num : numList) {
        sum += num;
      }

      if (sum % 9 == 0) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }

    } catch (Exception e) {
      System.out.println("エラー" + e);
    }
  }

  // int 2147483648 [ 2 * 10(9)]
  // long 9223372036854775808 [ 9 * 10(18)]

  public static int parseI(String value) {
    return Integer.parseInt(value);
  }

  public static long parseL(String value) {
    return Long.parseLong(value);
  }

  public static double parseD(String value) {
    return Double.parseDouble(value);
  }

  public static <T> String parseS(T value) {
    return String.valueOf(value);
  }

  public static BigDecimal parseBigD(String value) {
    return new BigDecimal(value);
  }

  public static BigInteger parseBigI(String value) {
    return new BigInteger(value);
  }

}
