import java.util.*;
import java.io.*;

class Main{
  static boolean found = false;
  public static void main(String[] args) throws IOException {
    PrintWriter out = new PrintWriter(System.out);
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    // StringTokenizer st  = new StringTokenizer(br.readLine());

    String s = br.readLine();

    long sum = 0;
    for (int i=0; i<s.length(); i++) {
      sum+= Character.getNumericValue(s.charAt(i));
      sum = sum%9;
    }
    if (sum%9==0) {
      out.println("Yes");
    }
    else {
      out.println("No");
    }
    out.close();
  }

  
}







 import java.util.*; util.* java import java.io.*; io.* java class Main{
  static boolean found = false;
  public static void main(String[] args) throws IOException {
    PrintWriter out = new PrintWriter(System.out);
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    // StringTokenizer st  = new StringTokenizer(br.readLine());

    String s = br.readLine();

    long sum = 0;
    for (int i=0; i<s.length(); i++) {
      sum+= Character.getNumericValue(s.charAt(i));
      sum = sum%9;
    }
    if (sum%9==0) {
      out.println("Yes");
    }
    else {
      out.println("No");
    }
    out.close();
  }

  
} Main static boolean found = false; found false public static void main(String[] args) throws IOException {
    PrintWriter out = new PrintWriter(System.out);
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    // StringTokenizer st  = new StringTokenizer(br.readLine());

    String s = br.readLine();

    long sum = 0;
    for (int i=0; i<s.length(); i++) {
      sum+= Character.getNumericValue(s.charAt(i));
      sum = sum%9;
    }
    if (sum%9==0) {
      out.println("Yes");
    }
    else {
      out.println("No");
    }
    out.close();
  } main {
    PrintWriter out = new PrintWriter(System.out);
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    // StringTokenizer st  = new StringTokenizer(br.readLine());

    String s = br.readLine();

    long sum = 0;
    for (int i=0; i<s.length(); i++) {
      sum+= Character.getNumericValue(s.charAt(i));
      sum = sum%9;
    }
    if (sum%9==0) {
      out.println("Yes");
    }
    else {
      out.println("No");
    }
    out.close();
  } PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String s = br.readLine(); s br.readLine() br.readLine br long sum = 0; sum 0 for (int i=0; i<s.length(); i++) {
      sum+= Character.getNumericValue(s.charAt(i));
      sum = sum%9;
    } int i=0; int i=0; i 0 i<s.length() i s.length() s.length s i++ i++ i {
      sum+= Character.getNumericValue(s.charAt(i));
      sum = sum%9;
    } {
      sum+= Character.getNumericValue(s.charAt(i));
      sum = sum%9;
    } sum+= Character.getNumericValue(s.charAt(i)) sum Character.getNumericValue(s.charAt(i)) Character.getNumericValue Character s.charAt(i) s.charAt s i sum = sum%9 sum sum%9 sum 9 if (sum%9==0) {
      out.println("Yes");
    }
    else {
      out.println("No");
    } sum%9==0 sum%9 sum 9 0 {
      out.println("Yes");
    } out.println("Yes") out.println out "Yes" {
      out.println("No");
    } out.println("No") out.println out "No" out.close() out.close out String[] args args
import java.util.*;
import java.io.*;

class Main{
  static boolean found = false;
  public static void main(String[] args) throws IOException {
    PrintWriter out = new PrintWriter(System.out);
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    // StringTokenizer st  = new StringTokenizer(br.readLine());

    String s = br.readLine();

    long sum = 0;
    for (int i=0; i<s.length(); i++) {
      sum+= Character.getNumericValue(s.charAt(i));
      sum = sum%9;
    }
    if (sum%9==0) {
      out.println("Yes");
    }
    else {
      out.println("No");
    }
    out.close();
  }

  
}








