import java.util.*;
import java.io.*;
import java.lang.*;
 
public class Main {

  static class FastReader {

    BufferedReader br; 
    StringTokenizer st; 

    public FastReader() { 
      br = new BufferedReader(new InputStreamReader(System.in)); 
    } 

    String next() { 
      while (st == null || !st.hasMoreElements()) { 
        try { 
          st = new StringTokenizer(br.readLine()); 
        } catch (IOException e) { 
          e.printStackTrace(); 
        } 
      } 
      return st.nextToken(); 
    } 

    int nextInt() { 
      return Integer.parseInt(next()); 
    } 

    long nextLong() { 
      return Long.parseLong(next()); 
    } 

    double nextDouble() { 
      return Double.parseDouble(next()); 
    } 

    String nextLine() { 
      String str = ""; 
      try { 
        str = br.readLine(); 
      } catch (IOException e) { 
        e.printStackTrace(); 
      } 
      return str; 
    } 
  }
 
  public static void main(String args[]) throws IOException {
    // try {
    //   FileOutputStream output = new FileOutputStream("temp.out");
    //   PrintStream out = new PrintStream(output);
    //   //Diverting the output stream into file "temp.out".Comment the below line to use console
    //   System.setOut(out);
  
    //   InputStream input = new FileInputStream("temp.in");
    //   //Diverting the input stream into file "temp.in".Comment the below line to use console
    //   System.setIn(input);
  
    // } catch (FileNotFoundException e) {
    //   e.printStackTrace();
    // }
  
    FastReader sc = new FastReader();
    PrintWriter wr = new PrintWriter(System.out);
 
    // int t = 1;
    // t = sc.nextInt();    //Comment this line if there is single test case

    // while((t--) != 0) {

    // }    

    String str = sc.nextLine();
    int ans = 0;

    for(int i = 0; i < str.length(); i++) {
        
        char ch = str.charAt(i);
        String str1 = String.valueOf(ch);
        ans += Integer.parseInt(str1);  
    }

    if((ans % 9) == 0) {
      wr.println("Yes");
    } else {
      wr.println("No");
    }
        
    wr.flush();
    wr.close();
  }
} import java.util.*; util.* java import java.io.*; io.* java import java.lang.*; lang.* java public class Main {

  static class FastReader {

    BufferedReader br; 
    StringTokenizer st; 

    public FastReader() { 
      br = new BufferedReader(new InputStreamReader(System.in)); 
    } 

    String next() { 
      while (st == null || !st.hasMoreElements()) { 
        try { 
          st = new StringTokenizer(br.readLine()); 
        } catch (IOException e) { 
          e.printStackTrace(); 
        } 
      } 
      return st.nextToken(); 
    } 

    int nextInt() { 
      return Integer.parseInt(next()); 
    } 

    long nextLong() { 
      return Long.parseLong(next()); 
    } 

    double nextDouble() { 
      return Double.parseDouble(next()); 
    } 

    String nextLine() { 
      String str = ""; 
      try { 
        str = br.readLine(); 
      } catch (IOException e) { 
        e.printStackTrace(); 
      } 
      return str; 
    } 
  }
 
  public static void main(String args[]) throws IOException {
    // try {
    //   FileOutputStream output = new FileOutputStream("temp.out");
    //   PrintStream out = new PrintStream(output);
    //   //Diverting the output stream into file "temp.out".Comment the below line to use console
    //   System.setOut(out);
  
    //   InputStream input = new FileInputStream("temp.in");
    //   //Diverting the input stream into file "temp.in".Comment the below line to use console
    //   System.setIn(input);
  
    // } catch (FileNotFoundException e) {
    //   e.printStackTrace();
    // }
  
    FastReader sc = new FastReader();
    PrintWriter wr = new PrintWriter(System.out);
 
    // int t = 1;
    // t = sc.nextInt();    //Comment this line if there is single test case

    // while((t--) != 0) {

    // }    

    String str = sc.nextLine();
    int ans = 0;

    for(int i = 0; i < str.length(); i++) {
        
        char ch = str.charAt(i);
        String str1 = String.valueOf(ch);
        ans += Integer.parseInt(str1);  
    }

    if((ans % 9) == 0) {
      wr.println("Yes");
    } else {
      wr.println("No");
    }
        
    wr.flush();
    wr.close();
  }
} Main public static void main(String args[]) throws IOException {
    // try {
    //   FileOutputStream output = new FileOutputStream("temp.out");
    //   PrintStream out = new PrintStream(output);
    //   //Diverting the output stream into file "temp.out".Comment the below line to use console
    //   System.setOut(out);
  
    //   InputStream input = new FileInputStream("temp.in");
    //   //Diverting the input stream into file "temp.in".Comment the below line to use console
    //   System.setIn(input);
  
    // } catch (FileNotFoundException e) {
    //   e.printStackTrace();
    // }
  
    FastReader sc = new FastReader();
    PrintWriter wr = new PrintWriter(System.out);
 
    // int t = 1;
    // t = sc.nextInt();    //Comment this line if there is single test case

    // while((t--) != 0) {

    // }    

    String str = sc.nextLine();
    int ans = 0;

    for(int i = 0; i < str.length(); i++) {
        
        char ch = str.charAt(i);
        String str1 = String.valueOf(ch);
        ans += Integer.parseInt(str1);  
    }

    if((ans % 9) == 0) {
      wr.println("Yes");
    } else {
      wr.println("No");
    }
        
    wr.flush();
    wr.close();
  } main {
    // try {
    //   FileOutputStream output = new FileOutputStream("temp.out");
    //   PrintStream out = new PrintStream(output);
    //   //Diverting the output stream into file "temp.out".Comment the below line to use console
    //   System.setOut(out);
  
    //   InputStream input = new FileInputStream("temp.in");
    //   //Diverting the input stream into file "temp.in".Comment the below line to use console
    //   System.setIn(input);
  
    // } catch (FileNotFoundException e) {
    //   e.printStackTrace();
    // }
  
    FastReader sc = new FastReader();
    PrintWriter wr = new PrintWriter(System.out);
 
    // int t = 1;
    // t = sc.nextInt();    //Comment this line if there is single test case

    // while((t--) != 0) {

    // }    

    String str = sc.nextLine();
    int ans = 0;

    for(int i = 0; i < str.length(); i++) {
        
        char ch = str.charAt(i);
        String str1 = String.valueOf(ch);
        ans += Integer.parseInt(str1);  
    }

    if((ans % 9) == 0) {
      wr.println("Yes");
    } else {
      wr.println("No");
    }
        
    wr.flush();
    wr.close();
  } FastReader sc = new FastReader(); sc new FastReader() PrintWriter wr = new PrintWriter(System.out); wr new PrintWriter(System.out) String str = sc.nextLine(); str sc.nextLine() sc.nextLine sc int ans = 0; ans 0 for(int i = 0; i < str.length(); i++) {
        
        char ch = str.charAt(i);
        String str1 = String.valueOf(ch);
        ans += Integer.parseInt(str1);  
    } int i = 0; int i = 0; i 0 i < str.length() i str.length() str.length str i++ i++ i {
        
        char ch = str.charAt(i);
        String str1 = String.valueOf(ch);
        ans += Integer.parseInt(str1);  
    } {
        
        char ch = str.charAt(i);
        String str1 = String.valueOf(ch);
        ans += Integer.parseInt(str1);  
    } char ch = str.charAt(i); ch str.charAt(i) str.charAt str i String str1 = String.valueOf(ch); str1 String.valueOf(ch) String.valueOf String ch ans += Integer.parseInt(str1) ans Integer.parseInt(str1) Integer.parseInt Integer str1 if((ans % 9) == 0) {
      wr.println("Yes");
    } else {
      wr.println("No");
    } (ans % 9) == 0 (ans % 9) ans 9 0 {
      wr.println("Yes");
    } wr.println("Yes") wr.println wr "Yes" {
      wr.println("No");
    } wr.println("No") wr.println wr "No" wr.flush() wr.flush wr wr.close() wr.close wr String args[] args static class FastReader {

    BufferedReader br; 
    StringTokenizer st; 

    public FastReader() { 
      br = new BufferedReader(new InputStreamReader(System.in)); 
    } 

    String next() { 
      while (st == null || !st.hasMoreElements()) { 
        try { 
          st = new StringTokenizer(br.readLine()); 
        } catch (IOException e) { 
          e.printStackTrace(); 
        } 
      } 
      return st.nextToken(); 
    } 

    int nextInt() { 
      return Integer.parseInt(next()); 
    } 

    long nextLong() { 
      return Long.parseLong(next()); 
    } 

    double nextDouble() { 
      return Double.parseDouble(next()); 
    } 

    String nextLine() { 
      String str = ""; 
      try { 
        str = br.readLine(); 
      } catch (IOException e) { 
        e.printStackTrace(); 
      } 
      return str; 
    } 
  } FastReader BufferedReader br; br StringTokenizer st; st public FastReader() { 
      br = new BufferedReader(new InputStreamReader(System.in)); 
    } FastReader { 
      br = new BufferedReader(new InputStreamReader(System.in)); 
    } br = new BufferedReader(new InputStreamReader(System.in)) br new BufferedReader(new InputStreamReader(System.in)) String next() { 
      while (st == null || !st.hasMoreElements()) { 
        try { 
          st = new StringTokenizer(br.readLine()); 
        } catch (IOException e) { 
          e.printStackTrace(); 
        } 
      } 
      return st.nextToken(); 
    } next { 
      while (st == null || !st.hasMoreElements()) { 
        try { 
          st = new StringTokenizer(br.readLine()); 
        } catch (IOException e) { 
          e.printStackTrace(); 
        } 
      } 
      return st.nextToken(); 
    } while (st == null || !st.hasMoreElements()) { 
        try { 
          st = new StringTokenizer(br.readLine()); 
        } catch (IOException e) { 
          e.printStackTrace(); 
        } 
      } st == null || !st.hasMoreElements() st == null st null !st.hasMoreElements() st.hasMoreElements() st.hasMoreElements st { 
        try { 
          st = new StringTokenizer(br.readLine()); 
        } catch (IOException e) { 
          e.printStackTrace(); 
        } 
      } try { 
          st = new StringTokenizer(br.readLine()); 
        } catch (IOException e) { 
          e.printStackTrace(); 
        } catch (IOException e) { 
          e.printStackTrace(); 
        } IOException e { 
          e.printStackTrace(); 
        } e.printStackTrace() e.printStackTrace e { 
          st = new StringTokenizer(br.readLine()); 
        } st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) return st.nextToken(); st.nextToken() st.nextToken st int nextInt() { 
      return Integer.parseInt(next()); 
    } nextInt { 
      return Integer.parseInt(next()); 
    } return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next long nextLong() { 
      return Long.parseLong(next()); 
    } nextLong { 
      return Long.parseLong(next()); 
    } return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next double nextDouble() { 
      return Double.parseDouble(next()); 
    } nextDouble { 
      return Double.parseDouble(next()); 
    } return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next String nextLine() { 
      String str = ""; 
      try { 
        str = br.readLine(); 
      } catch (IOException e) { 
        e.printStackTrace(); 
      } 
      return str; 
    } nextLine { 
      String str = ""; 
      try { 
        str = br.readLine(); 
      } catch (IOException e) { 
        e.printStackTrace(); 
      } 
      return str; 
    } String str = ""; str "" try { 
        str = br.readLine(); 
      } catch (IOException e) { 
        e.printStackTrace(); 
      } catch (IOException e) { 
        e.printStackTrace(); 
      } IOException e { 
        e.printStackTrace(); 
      } e.printStackTrace() e.printStackTrace e { 
        str = br.readLine(); 
      } str = br.readLine() str br.readLine() br.readLine br return str; str public class Main {

  static class FastReader {

    BufferedReader br; 
    StringTokenizer st; 

    public FastReader() { 
      br = new BufferedReader(new InputStreamReader(System.in)); 
    } 

    String next() { 
      while (st == null || !st.hasMoreElements()) { 
        try { 
          st = new StringTokenizer(br.readLine()); 
        } catch (IOException e) { 
          e.printStackTrace(); 
        } 
      } 
      return st.nextToken(); 
    } 

    int nextInt() { 
      return Integer.parseInt(next()); 
    } 

    long nextLong() { 
      return Long.parseLong(next()); 
    } 

    double nextDouble() { 
      return Double.parseDouble(next()); 
    } 

    String nextLine() { 
      String str = ""; 
      try { 
        str = br.readLine(); 
      } catch (IOException e) { 
        e.printStackTrace(); 
      } 
      return str; 
    } 
  }
 
  public static void main(String args[]) throws IOException {
    // try {
    //   FileOutputStream output = new FileOutputStream("temp.out");
    //   PrintStream out = new PrintStream(output);
    //   //Diverting the output stream into file "temp.out".Comment the below line to use console
    //   System.setOut(out);
  
    //   InputStream input = new FileInputStream("temp.in");
    //   //Diverting the input stream into file "temp.in".Comment the below line to use console
    //   System.setIn(input);
  
    // } catch (FileNotFoundException e) {
    //   e.printStackTrace();
    // }
  
    FastReader sc = new FastReader();
    PrintWriter wr = new PrintWriter(System.out);
 
    // int t = 1;
    // t = sc.nextInt();    //Comment this line if there is single test case

    // while((t--) != 0) {

    // }    

    String str = sc.nextLine();
    int ans = 0;

    for(int i = 0; i < str.length(); i++) {
        
        char ch = str.charAt(i);
        String str1 = String.valueOf(ch);
        ans += Integer.parseInt(str1);  
    }

    if((ans % 9) == 0) {
      wr.println("Yes");
    } else {
      wr.println("No");
    }
        
    wr.flush();
    wr.close();
  }
} public class Main {

  static class FastReader {

    BufferedReader br; 
    StringTokenizer st; 

    public FastReader() { 
      br = new BufferedReader(new InputStreamReader(System.in)); 
    } 

    String next() { 
      while (st == null || !st.hasMoreElements()) { 
        try { 
          st = new StringTokenizer(br.readLine()); 
        } catch (IOException e) { 
          e.printStackTrace(); 
        } 
      } 
      return st.nextToken(); 
    } 

    int nextInt() { 
      return Integer.parseInt(next()); 
    } 

    long nextLong() { 
      return Long.parseLong(next()); 
    } 

    double nextDouble() { 
      return Double.parseDouble(next()); 
    } 

    String nextLine() { 
      String str = ""; 
      try { 
        str = br.readLine(); 
      } catch (IOException e) { 
        e.printStackTrace(); 
      } 
      return str; 
    } 
  }
 
  public static void main(String args[]) throws IOException {
    // try {
    //   FileOutputStream output = new FileOutputStream("temp.out");
    //   PrintStream out = new PrintStream(output);
    //   //Diverting the output stream into file "temp.out".Comment the below line to use console
    //   System.setOut(out);
  
    //   InputStream input = new FileInputStream("temp.in");
    //   //Diverting the input stream into file "temp.in".Comment the below line to use console
    //   System.setIn(input);
  
    // } catch (FileNotFoundException e) {
    //   e.printStackTrace();
    // }
  
    FastReader sc = new FastReader();
    PrintWriter wr = new PrintWriter(System.out);
 
    // int t = 1;
    // t = sc.nextInt();    //Comment this line if there is single test case

    // while((t--) != 0) {

    // }    

    String str = sc.nextLine();
    int ans = 0;

    for(int i = 0; i < str.length(); i++) {
        
        char ch = str.charAt(i);
        String str1 = String.valueOf(ch);
        ans += Integer.parseInt(str1);  
    }

    if((ans % 9) == 0) {
      wr.println("Yes");
    } else {
      wr.println("No");
    }
        
    wr.flush();
    wr.close();
  }
} Main
import java.util.*;
import java.io.*;
import java.lang.*;
 
public class Main {

  static class FastReader {

    BufferedReader br; 
    StringTokenizer st; 

    public FastReader() { 
      br = new BufferedReader(new InputStreamReader(System.in)); 
    } 

    String next() { 
      while (st == null || !st.hasMoreElements()) { 
        try { 
          st = new StringTokenizer(br.readLine()); 
        } catch (IOException e) { 
          e.printStackTrace(); 
        } 
      } 
      return st.nextToken(); 
    } 

    int nextInt() { 
      return Integer.parseInt(next()); 
    } 

    long nextLong() { 
      return Long.parseLong(next()); 
    } 

    double nextDouble() { 
      return Double.parseDouble(next()); 
    } 

    String nextLine() { 
      String str = ""; 
      try { 
        str = br.readLine(); 
      } catch (IOException e) { 
        e.printStackTrace(); 
      } 
      return str; 
    } 
  }
 
  public static void main(String args[]) throws IOException {
    // try {
    //   FileOutputStream output = new FileOutputStream("temp.out");
    //   PrintStream out = new PrintStream(output);
    //   //Diverting the output stream into file "temp.out".Comment the below line to use console
    //   System.setOut(out);
  
    //   InputStream input = new FileInputStream("temp.in");
    //   //Diverting the input stream into file "temp.in".Comment the below line to use console
    //   System.setIn(input);
  
    // } catch (FileNotFoundException e) {
    //   e.printStackTrace();
    // }
  
    FastReader sc = new FastReader();
    PrintWriter wr = new PrintWriter(System.out);
 
    // int t = 1;
    // t = sc.nextInt();    //Comment this line if there is single test case

    // while((t--) != 0) {

    // }    

    String str = sc.nextLine();
    int ans = 0;

    for(int i = 0; i < str.length(); i++) {
        
        char ch = str.charAt(i);
        String str1 = String.valueOf(ch);
        ans += Integer.parseInt(str1);  
    }

    if((ans % 9) == 0) {
      wr.println("Yes");
    } else {
      wr.println("No");
    }
        
    wr.flush();
    wr.close();
  }
}