import java.util.*;
import static java.lang.System.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
      String s = sc.next();
      int sum = 0;
      
      for(int i=0; i<s.length(); i++){
        sum = sum + (s.charAt(i)-'0');
      }
    if(sum % 9 ==0){
      out.println("Yes");
}else{
      out.println("No");
    }
}
} import java.util.*; util.* java import static java.lang.System.*; import static java.lang.System.*; import static java.lang.System.*; class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
      String s = sc.next();
      int sum = 0;
      
      for(int i=0; i<s.length(); i++){
        sum = sum + (s.charAt(i)-'0');
      }
    if(sum % 9 ==0){
      out.println("Yes");
}else{
      out.println("No");
    }
}
} Main public static void main(String[] args){
        Scanner sc = new Scanner(in);
      String s = sc.next();
      int sum = 0;
      
      for(int i=0; i<s.length(); i++){
        sum = sum + (s.charAt(i)-'0');
      }
    if(sum % 9 ==0){
      out.println("Yes");
}else{
      out.println("No");
    }
} main {
        Scanner sc = new Scanner(in);
      String s = sc.next();
      int sum = 0;
      
      for(int i=0; i<s.length(); i++){
        sum = sum + (s.charAt(i)-'0');
      }
    if(sum % 9 ==0){
      out.println("Yes");
}else{
      out.println("No");
    }
} Scanner sc = new Scanner(in); sc new Scanner(in) String s = sc.next(); s sc.next() sc.next sc int sum = 0; sum 0 for(int i=0; i<s.length(); i++){
        sum = sum + (s.charAt(i)-'0');
      } int i=0; int i=0; i 0 i<s.length() i s.length() s.length s i++ i++ i {
        sum = sum + (s.charAt(i)-'0');
      } {
        sum = sum + (s.charAt(i)-'0');
      } sum = sum + (s.charAt(i)-'0') sum sum + (s.charAt(i)-'0') sum (s.charAt(i)-'0') s.charAt(i) s.charAt s i '0' if(sum % 9 ==0){
      out.println("Yes");
}else{
      out.println("No");
    } sum % 9 ==0 sum % 9 sum 9 0 {
      out.println("Yes");
} out.println("Yes") out.println out "Yes" {
      out.println("No");
    } out.println("No") out.println out "No" String[] args args
import java.util.*;
import static java.lang.System.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
      String s = sc.next();
      int sum = 0;
      
      for(int i=0; i<s.length(); i++){
        sum = sum + (s.charAt(i)-'0');
      }
    if(sum % 9 ==0){
      out.println("Yes");
}else{
      out.println("No");
    }
}
}