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