import java.util.*;

class Main{

  public static void main(String args[]){

    Scanner s=new Scanner(System.in);
    String N=s.next();
    int box=0;
    int max=N.length();
    for(int i=0;i<max;i++){
      box+=N.charAt(i)-48;
    }
    System.out.println(box%9==0?"Yes":"No");
    
  }  
} import java.util.*; util.* java class Main{

  public static void main(String args[]){

    Scanner s=new Scanner(System.in);
    String N=s.next();
    int box=0;
    int max=N.length();
    for(int i=0;i<max;i++){
      box+=N.charAt(i)-48;
    }
    System.out.println(box%9==0?"Yes":"No");
    
  }  
} Main public static void main(String args[]){

    Scanner s=new Scanner(System.in);
    String N=s.next();
    int box=0;
    int max=N.length();
    for(int i=0;i<max;i++){
      box+=N.charAt(i)-48;
    }
    System.out.println(box%9==0?"Yes":"No");
    
  } main {

    Scanner s=new Scanner(System.in);
    String N=s.next();
    int box=0;
    int max=N.length();
    for(int i=0;i<max;i++){
      box+=N.charAt(i)-48;
    }
    System.out.println(box%9==0?"Yes":"No");
    
  } Scanner s=new Scanner(System.in); s new Scanner(System.in) String N=s.next(); N s.next() s.next s int box=0; box 0 int max=N.length(); max N.length() N.length N for(int i=0;i<max;i++){
      box+=N.charAt(i)-48;
    } int i=0; int i=0; i 0 i<max i max i++ i++ i {
      box+=N.charAt(i)-48;
    } {
      box+=N.charAt(i)-48;
    } box+=N.charAt(i)-48 box N.charAt(i)-48 N.charAt(i) N.charAt N i 48 System.out.println(box%9==0?"Yes":"No") System.out.println System.out System System.out box%9==0?"Yes":"No" box%9==0 box%9 box 9 0 "Yes" "No" String args[] args
import java.util.*;

class Main{

  public static void main(String args[]){

    Scanner s=new Scanner(System.in);
    String N=s.next();
    int box=0;
    int max=N.length();
    for(int i=0;i<max;i++){
      box+=N.charAt(i)-48;
    }
    System.out.println(box%9==0?"Yes":"No");
    
  }  
}