import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    // 入力値
    String input = sc.nextLine();

    int sum = 0;
    for (int i=0; i<input.length(); i++) {
      sum += Integer.parseInt(input.substring(i, i+1));
    }

    // 9で割れるか
    int amari = sum % 9;
    String result = amari == 0 ? "Yes" : "No";
    System.out.println(result);
  }
} import java.util.*; util.* java public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    // 入力値
    String input = sc.nextLine();

    int sum = 0;
    for (int i=0; i<input.length(); i++) {
      sum += Integer.parseInt(input.substring(i, i+1));
    }

    // 9で割れるか
    int amari = sum % 9;
    String result = amari == 0 ? "Yes" : "No";
    System.out.println(result);
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    // 入力値
    String input = sc.nextLine();

    int sum = 0;
    for (int i=0; i<input.length(); i++) {
      sum += Integer.parseInt(input.substring(i, i+1));
    }

    // 9で割れるか
    int amari = sum % 9;
    String result = amari == 0 ? "Yes" : "No";
    System.out.println(result);
  } main {
    Scanner sc = new Scanner(System.in);
    
    // 入力値
    String input = sc.nextLine();

    int sum = 0;
    for (int i=0; i<input.length(); i++) {
      sum += Integer.parseInt(input.substring(i, i+1));
    }

    // 9で割れるか
    int amari = sum % 9;
    String result = amari == 0 ? "Yes" : "No";
    System.out.println(result);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String input = sc.nextLine(); input sc.nextLine() sc.nextLine sc int sum = 0; sum 0 for (int i=0; i<input.length(); i++) {
      sum += Integer.parseInt(input.substring(i, i+1));
    } int i=0; int i=0; i 0 i<input.length() i input.length() input.length input i++ i++ i {
      sum += Integer.parseInt(input.substring(i, i+1));
    } {
      sum += Integer.parseInt(input.substring(i, i+1));
    } sum += Integer.parseInt(input.substring(i, i+1)) sum Integer.parseInt(input.substring(i, i+1)) Integer.parseInt Integer input.substring(i, i+1) input.substring input i i+1 i 1 int amari = sum % 9; amari sum % 9 sum 9 String result = amari == 0 ? "Yes" : "No"; result amari == 0 ? "Yes" : "No" amari == 0 amari 0 "Yes" "No" System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    // 入力値
    String input = sc.nextLine();

    int sum = 0;
    for (int i=0; i<input.length(); i++) {
      sum += Integer.parseInt(input.substring(i, i+1));
    }

    // 9で割れるか
    int amari = sum % 9;
    String result = amari == 0 ? "Yes" : "No";
    System.out.println(result);
  }
} public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    // 入力値
    String input = sc.nextLine();

    int sum = 0;
    for (int i=0; i<input.length(); i++) {
      sum += Integer.parseInt(input.substring(i, i+1));
    }

    // 9で割れるか
    int amari = sum % 9;
    String result = amari == 0 ? "Yes" : "No";
    System.out.println(result);
  }
} Main
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    // 入力値
    String input = sc.nextLine();

    int sum = 0;
    for (int i=0; i<input.length(); i++) {
      sum += Integer.parseInt(input.substring(i, i+1));
    }

    // 9で割れるか
    int amari = sum % 9;
    String result = amari == 0 ? "Yes" : "No";
    System.out.println(result);
  }
}
