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