import java.util.*;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String N = sc.nextLine();
        int min;
        int anc = 0;
        for(int i = 0;i < N.length();i++){
            min = (int)N.charAt(i);
          	min -=48;
            anc += min;
        }
        if(anc%9 == 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
} import java.util.*; util.* java public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String N = sc.nextLine();
        int min;
        int anc = 0;
        for(int i = 0;i < N.length();i++){
            min = (int)N.charAt(i);
          	min -=48;
            anc += min;
        }
        if(anc%9 == 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String N = sc.nextLine();
        int min;
        int anc = 0;
        for(int i = 0;i < N.length();i++){
            min = (int)N.charAt(i);
          	min -=48;
            anc += min;
        }
        if(anc%9 == 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    } main {
        Scanner sc = new Scanner(System.in);
        String N = sc.nextLine();
        int min;
        int anc = 0;
        for(int i = 0;i < N.length();i++){
            min = (int)N.charAt(i);
          	min -=48;
            anc += min;
        }
        if(anc%9 == 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String N = sc.nextLine(); N sc.nextLine() sc.nextLine sc int min; min int anc = 0; anc 0 for(int i = 0;i < N.length();i++){
            min = (int)N.charAt(i);
          	min -=48;
            anc += min;
        } int i = 0; int i = 0; i 0 i < N.length() i N.length() N.length N i++ i++ i {
            min = (int)N.charAt(i);
          	min -=48;
            anc += min;
        } {
            min = (int)N.charAt(i);
          	min -=48;
            anc += min;
        } min = (int)N.charAt(i) min (int)N.charAt(i) N.charAt N i min -=48 min 48 anc += min anc min if(anc%9 == 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        } anc%9 == 0 anc%9 anc 9 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 public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String N = sc.nextLine();
        int min;
        int anc = 0;
        for(int i = 0;i < N.length();i++){
            min = (int)N.charAt(i);
          	min -=48;
            anc += min;
        }
        if(anc%9 == 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
} public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String N = sc.nextLine();
        int min;
        int anc = 0;
        for(int i = 0;i < N.length();i++){
            min = (int)N.charAt(i);
          	min -=48;
            anc += min;
        }
        if(anc%9 == 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
} Main
import java.util.*;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String N = sc.nextLine();
        int min;
        int anc = 0;
        for(int i = 0;i < N.length();i++){
            min = (int)N.charAt(i);
          	min -=48;
            anc += min;
        }
        if(anc%9 == 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}
