import java.util.Scanner;
  public class Main {
    public static void main(String[] args) {
      Scanner scan = new Scanner(System.in);
      String N = scan.next();
      String M = "";
      int cnt = 0;
      for(int i=N.length(); i>0; i--){
        M = N.substring(i-1,i);
        cnt += Integer.parseInt(M);
      }
      if(cnt%9==0){
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }
    }
  } import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
      Scanner scan = new Scanner(System.in);
      String N = scan.next();
      String M = "";
      int cnt = 0;
      for(int i=N.length(); i>0; i--){
        M = N.substring(i-1,i);
        cnt += Integer.parseInt(M);
      }
      if(cnt%9==0){
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }
    }
  } Main public static void main(String[] args) {
      Scanner scan = new Scanner(System.in);
      String N = scan.next();
      String M = "";
      int cnt = 0;
      for(int i=N.length(); i>0; i--){
        M = N.substring(i-1,i);
        cnt += Integer.parseInt(M);
      }
      if(cnt%9==0){
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }
    } main {
      Scanner scan = new Scanner(System.in);
      String N = scan.next();
      String M = "";
      int cnt = 0;
      for(int i=N.length(); i>0; i--){
        M = N.substring(i-1,i);
        cnt += Integer.parseInt(M);
      }
      if(cnt%9==0){
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String N = scan.next(); N scan.next() scan.next scan String M = ""; M "" int cnt = 0; cnt 0 for(int i=N.length(); i>0; i--){
        M = N.substring(i-1,i);
        cnt += Integer.parseInt(M);
      } int i=N.length(); int i=N.length(); i N.length() N.length N i>0 i 0 i-- i-- i {
        M = N.substring(i-1,i);
        cnt += Integer.parseInt(M);
      } {
        M = N.substring(i-1,i);
        cnt += Integer.parseInt(M);
      } M = N.substring(i-1,i) M N.substring(i-1,i) N.substring N i-1 i 1 i cnt += Integer.parseInt(M) cnt Integer.parseInt(M) Integer.parseInt Integer M if(cnt%9==0){
        System.out.println("Yes");
      } else {
        System.out.println("No");
      } cnt%9==0 cnt%9 cnt 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" String[] args args public class Main {
    public static void main(String[] args) {
      Scanner scan = new Scanner(System.in);
      String N = scan.next();
      String M = "";
      int cnt = 0;
      for(int i=N.length(); i>0; i--){
        M = N.substring(i-1,i);
        cnt += Integer.parseInt(M);
      }
      if(cnt%9==0){
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }
    }
  } public class Main {
    public static void main(String[] args) {
      Scanner scan = new Scanner(System.in);
      String N = scan.next();
      String M = "";
      int cnt = 0;
      for(int i=N.length(); i>0; i--){
        M = N.substring(i-1,i);
        cnt += Integer.parseInt(M);
      }
      if(cnt%9==0){
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }
    }
  } Main
import java.util.Scanner;
  public class Main {
    public static void main(String[] args) {
      Scanner scan = new Scanner(System.in);
      String N = scan.next();
      String M = "";
      int cnt = 0;
      for(int i=N.length(); i>0; i--){
        M = N.substring(i-1,i);
        cnt += Integer.parseInt(M);
      }
      if(cnt%9==0){
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }
    }
  }