import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        String N = sc.next();
        char[] n = N.toCharArray();
        int nine = 0;
        for(int i = 0; i < N.length(); i++){
          nine += Character.getNumericValue(n[i]);
        }
        String ans = "Yes";
      if(nine % 9 != 0 ) ans = "No";
      System.out.println(ans);
    } 
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        String N = sc.next();
        char[] n = N.toCharArray();
        int nine = 0;
        for(int i = 0; i < N.length(); i++){
          nine += Character.getNumericValue(n[i]);
        }
        String ans = "Yes";
      if(nine % 9 != 0 ) ans = "No";
      System.out.println(ans);
    } 
} Main public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        String N = sc.next();
        char[] n = N.toCharArray();
        int nine = 0;
        for(int i = 0; i < N.length(); i++){
          nine += Character.getNumericValue(n[i]);
        }
        String ans = "Yes";
      if(nine % 9 != 0 ) ans = "No";
      System.out.println(ans);
    } main {
        Scanner sc= new Scanner(System.in);
        String N = sc.next();
        char[] n = N.toCharArray();
        int nine = 0;
        for(int i = 0; i < N.length(); i++){
          nine += Character.getNumericValue(n[i]);
        }
        String ans = "Yes";
      if(nine % 9 != 0 ) ans = "No";
      System.out.println(ans);
    } Scanner sc= new Scanner(System.in); sc new Scanner(System.in) String N = sc.next(); N sc.next() sc.next sc char[] n = N.toCharArray(); n N.toCharArray() N.toCharArray N int nine = 0; nine 0 for(int i = 0; i < N.length(); i++){
          nine += Character.getNumericValue(n[i]);
        } int i = 0; int i = 0; i 0 i < N.length() i N.length() N.length N i++ i++ i {
          nine += Character.getNumericValue(n[i]);
        } {
          nine += Character.getNumericValue(n[i]);
        } nine += Character.getNumericValue(n[i]) nine Character.getNumericValue(n[i]) Character.getNumericValue Character n[i] n i String ans = "Yes"; ans "Yes" if(nine % 9 != 0 ) ans = "No"; nine % 9 != 0 nine % 9 nine 9 0 ans = "No" ans "No" System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        String N = sc.next();
        char[] n = N.toCharArray();
        int nine = 0;
        for(int i = 0; i < N.length(); i++){
          nine += Character.getNumericValue(n[i]);
        }
        String ans = "Yes";
      if(nine % 9 != 0 ) ans = "No";
      System.out.println(ans);
    } 
} public class Main {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        String N = sc.next();
        char[] n = N.toCharArray();
        int nine = 0;
        for(int i = 0; i < N.length(); i++){
          nine += Character.getNumericValue(n[i]);
        }
        String ans = "Yes";
      if(nine % 9 != 0 ) ans = "No";
      System.out.println(ans);
    } 
} Main
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        String N = sc.next();
        char[] n = N.toCharArray();
        int nine = 0;
        for(int i = 0; i < N.length(); i++){
          nine += Character.getNumericValue(n[i]);
        }
        String ans = "Yes";
      if(nine % 9 != 0 ) ans = "No";
      System.out.println(ans);
    } 
}