import java.util.Scanner;
import java.util.Comparator;
import java.util.Arrays;
import java.util.Collections;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    String S = scan.next();
    String[] split = S.split("");
    int N = S.length();
    long add = 0;
    for(int i = 0; i < N; i++){
      int a = Integer.valueOf(split[i]);
      add += a;
    }
    if(add % 9 == 0){
      System.out.println("Yes");
    }
	else{
      System.out.println("No");
    }
  }
}
     import java.util.Scanner; Scanner java.util import java.util.Comparator; Comparator java.util import java.util.Arrays; Arrays java.util import java.util.Collections; Collections java.util class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    String S = scan.next();
    String[] split = S.split("");
    int N = S.length();
    long add = 0;
    for(int i = 0; i < N; i++){
      int a = Integer.valueOf(split[i]);
      add += a;
    }
    if(add % 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 S = scan.next();
    String[] split = S.split("");
    int N = S.length();
    long add = 0;
    for(int i = 0; i < N; i++){
      int a = Integer.valueOf(split[i]);
      add += a;
    }
    if(add % 9 == 0){
      System.out.println("Yes");
    }
	else{
      System.out.println("No");
    }
  } main {
    Scanner scan = new Scanner(System.in);
    String S = scan.next();
    String[] split = S.split("");
    int N = S.length();
    long add = 0;
    for(int i = 0; i < N; i++){
      int a = Integer.valueOf(split[i]);
      add += a;
    }
    if(add % 9 == 0){
      System.out.println("Yes");
    }
	else{
      System.out.println("No");
    }
  } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String S = scan.next(); S scan.next() scan.next scan String[] split = S.split(""); split S.split("") S.split S "" int N = S.length(); N S.length() S.length S long add = 0; add 0 for(int i = 0; i < N; i++){
      int a = Integer.valueOf(split[i]);
      add += a;
    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
      int a = Integer.valueOf(split[i]);
      add += a;
    } {
      int a = Integer.valueOf(split[i]);
      add += a;
    } int a = Integer.valueOf(split[i]); a Integer.valueOf(split[i]) Integer.valueOf Integer split[i] split i add += a add a if(add % 9 == 0){
      System.out.println("Yes");
    }
	else{
      System.out.println("No");
    } add % 9 == 0 add % 9 add 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
import java.util.Scanner;
import java.util.Comparator;
import java.util.Arrays;
import java.util.Collections;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    String S = scan.next();
    String[] split = S.split("");
    int N = S.length();
    long add = 0;
    for(int i = 0; i < N; i++){
      int a = Integer.valueOf(split[i]);
      add += a;
    }
    if(add % 9 == 0){
      System.out.println("Yes");
    }
	else{
      System.out.println("No");
    }
  }
}
    