import java.util.*;
class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
  char c[]=sc.next().toCharArray();
  int ans=0;
  for(int i=0;i<c.length;i++){
    ans+=(c[i]-'0');
  }System.out.println(ans%9==0?"Yes":"No");
}
} import java.util.*; util.* java class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
  char c[]=sc.next().toCharArray();
  int ans=0;
  for(int i=0;i<c.length;i++){
    ans+=(c[i]-'0');
  }System.out.println(ans%9==0?"Yes":"No");
}
} Main public static void main(String[]args){
Scanner sc=new Scanner(System.in);
  char c[]=sc.next().toCharArray();
  int ans=0;
  for(int i=0;i<c.length;i++){
    ans+=(c[i]-'0');
  }System.out.println(ans%9==0?"Yes":"No");
} main {
Scanner sc=new Scanner(System.in);
  char c[]=sc.next().toCharArray();
  int ans=0;
  for(int i=0;i<c.length;i++){
    ans+=(c[i]-'0');
  }System.out.println(ans%9==0?"Yes":"No");
} Scanner sc=new Scanner(System.in); sc new Scanner(System.in) char c[]=sc.next().toCharArray(); c sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc int ans=0; ans 0 for(int i=0;i<c.length;i++){
    ans+=(c[i]-'0');
  } int i=0; int i=0; i 0 i<c.length i c.length c c.length i++ i++ i {
    ans+=(c[i]-'0');
  } {
    ans+=(c[i]-'0');
  } ans+=(c[i]-'0') ans (c[i]-'0') c[i] c i '0' System.out.println(ans%9==0?"Yes":"No") System.out.println System.out System System.out ans%9==0?"Yes":"No" ans%9==0 ans%9 ans 9 0 "Yes" "No" String[]args args
import java.util.*;
class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
  char c[]=sc.next().toCharArray();
  int ans=0;
  for(int i=0;i<c.length;i++){
    ans+=(c[i]-'0');
  }System.out.println(ans%9==0?"Yes":"No");
}
}