

import java.util.Map.Entry;
import java.util.*;
 
//import org.w3c.dom.css.Counter;
 
public class Main {
//public class App {
 
    public static void main(final String[] args){
     //スキャン
     final Scanner s = new Scanner(System.in);
      //String N = Integer.parseInt(s.next());
      //int X = Integer.parseInt(s.next());
      //int T = Integer.parseInt(s.next());
      //int ans = N /X;
      String hoge = s.next();
      int huge = hoge.length();
      int hage = 0;
    for(int i =0;i<huge;i++){
        hage += Integer.parseInt(hoge.substring(i, i+1));
    }


      String ans ="Yes";
      if(hage%9 !=0){ans = "No";}
      System.out.println(ans);
      
    }
} import java.util.Map.Entry; Entry java.util.Map import java.util.*; util.* java public class Main {
//public class App {
 
    public static void main(final String[] args){
     //スキャン
     final Scanner s = new Scanner(System.in);
      //String N = Integer.parseInt(s.next());
      //int X = Integer.parseInt(s.next());
      //int T = Integer.parseInt(s.next());
      //int ans = N /X;
      String hoge = s.next();
      int huge = hoge.length();
      int hage = 0;
    for(int i =0;i<huge;i++){
        hage += Integer.parseInt(hoge.substring(i, i+1));
    }


      String ans ="Yes";
      if(hage%9 !=0){ans = "No";}
      System.out.println(ans);
      
    }
} Main public static void main(final String[] args){
     //スキャン
     final Scanner s = new Scanner(System.in);
      //String N = Integer.parseInt(s.next());
      //int X = Integer.parseInt(s.next());
      //int T = Integer.parseInt(s.next());
      //int ans = N /X;
      String hoge = s.next();
      int huge = hoge.length();
      int hage = 0;
    for(int i =0;i<huge;i++){
        hage += Integer.parseInt(hoge.substring(i, i+1));
    }


      String ans ="Yes";
      if(hage%9 !=0){ans = "No";}
      System.out.println(ans);
      
    } main {
     //スキャン
     final Scanner s = new Scanner(System.in);
      //String N = Integer.parseInt(s.next());
      //int X = Integer.parseInt(s.next());
      //int T = Integer.parseInt(s.next());
      //int ans = N /X;
      String hoge = s.next();
      int huge = hoge.length();
      int hage = 0;
    for(int i =0;i<huge;i++){
        hage += Integer.parseInt(hoge.substring(i, i+1));
    }


      String ans ="Yes";
      if(hage%9 !=0){ans = "No";}
      System.out.println(ans);
      
    } final Scanner s = new Scanner(System.in); s new Scanner(System.in) String hoge = s.next(); hoge s.next() s.next s int huge = hoge.length(); huge hoge.length() hoge.length hoge int hage = 0; hage 0 for(int i =0;i<huge;i++){
        hage += Integer.parseInt(hoge.substring(i, i+1));
    } int i =0; int i =0; i 0 i<huge i huge i++ i++ i {
        hage += Integer.parseInt(hoge.substring(i, i+1));
    } {
        hage += Integer.parseInt(hoge.substring(i, i+1));
    } hage += Integer.parseInt(hoge.substring(i, i+1)) hage Integer.parseInt(hoge.substring(i, i+1)) Integer.parseInt Integer hoge.substring(i, i+1) hoge.substring hoge i i+1 i 1 String ans ="Yes"; ans "Yes" if(hage%9 !=0){ans = "No";} hage%9 !=0 hage%9 hage 9 0 {ans = "No";} ans = "No" ans "No" System.out.println(ans) System.out.println System.out System System.out ans final String[] args args public class Main {
//public class App {
 
    public static void main(final String[] args){
     //スキャン
     final Scanner s = new Scanner(System.in);
      //String N = Integer.parseInt(s.next());
      //int X = Integer.parseInt(s.next());
      //int T = Integer.parseInt(s.next());
      //int ans = N /X;
      String hoge = s.next();
      int huge = hoge.length();
      int hage = 0;
    for(int i =0;i<huge;i++){
        hage += Integer.parseInt(hoge.substring(i, i+1));
    }


      String ans ="Yes";
      if(hage%9 !=0){ans = "No";}
      System.out.println(ans);
      
    }
} public class Main {
//public class App {
 
    public static void main(final String[] args){
     //スキャン
     final Scanner s = new Scanner(System.in);
      //String N = Integer.parseInt(s.next());
      //int X = Integer.parseInt(s.next());
      //int T = Integer.parseInt(s.next());
      //int ans = N /X;
      String hoge = s.next();
      int huge = hoge.length();
      int hage = 0;
    for(int i =0;i<huge;i++){
        hage += Integer.parseInt(hoge.substring(i, i+1));
    }


      String ans ="Yes";
      if(hage%9 !=0){ans = "No";}
      System.out.println(ans);
      
    }
} Main


import java.util.Map.Entry;
import java.util.*;
 
//import org.w3c.dom.css.Counter;
 
public class Main {
//public class App {
 
    public static void main(final String[] args){
     //スキャン
     final Scanner s = new Scanner(System.in);
      //String N = Integer.parseInt(s.next());
      //int X = Integer.parseInt(s.next());
      //int T = Integer.parseInt(s.next());
      //int ans = N /X;
      String hoge = s.next();
      int huge = hoge.length();
      int hage = 0;
    for(int i =0;i<huge;i++){
        hage += Integer.parseInt(hoge.substring(i, i+1));
    }


      String ans ="Yes";
      if(hage%9 !=0){ans = "No";}
      System.out.println(ans);
      
    }
}
