import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n = sc.nextLine();
        long[] a = new long[n.length()];
        int ans = 0;
        for(int p = 0; p < n.length(); p++){
            a[p] = Long.parseLong(String.valueOf(n.charAt(p)));
            ans += a[p];
        }
        if(ans % 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();
        long[] a = new long[n.length()];
        int ans = 0;
        for(int p = 0; p < n.length(); p++){
            a[p] = Long.parseLong(String.valueOf(n.charAt(p)));
            ans += a[p];
        }
        if(ans % 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();
        long[] a = new long[n.length()];
        int ans = 0;
        for(int p = 0; p < n.length(); p++){
            a[p] = Long.parseLong(String.valueOf(n.charAt(p)));
            ans += a[p];
        }
        if(ans % 9 == 0){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }

    } main {
        Scanner sc = new Scanner(System.in);
        String n = sc.nextLine();
        long[] a = new long[n.length()];
        int ans = 0;
        for(int p = 0; p < n.length(); p++){
            a[p] = Long.parseLong(String.valueOf(n.charAt(p)));
            ans += a[p];
        }
        if(ans % 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 long[] a = new long[n.length()]; a new long[n.length()] n.length() n.length n int ans = 0; ans 0 for(int p = 0; p < n.length(); p++){
            a[p] = Long.parseLong(String.valueOf(n.charAt(p)));
            ans += a[p];
        } int p = 0; int p = 0; p 0 p < n.length() p n.length() n.length n p++ p++ p {
            a[p] = Long.parseLong(String.valueOf(n.charAt(p)));
            ans += a[p];
        } {
            a[p] = Long.parseLong(String.valueOf(n.charAt(p)));
            ans += a[p];
        } a[p] = Long.parseLong(String.valueOf(n.charAt(p))) a[p] a p Long.parseLong(String.valueOf(n.charAt(p))) Long.parseLong Long String.valueOf(n.charAt(p)) String.valueOf String n.charAt(p) n.charAt n p ans += a[p] ans a[p] a p if(ans % 9 == 0){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        } ans % 9 == 0 ans % 9 ans 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();
        long[] a = new long[n.length()];
        int ans = 0;
        for(int p = 0; p < n.length(); p++){
            a[p] = Long.parseLong(String.valueOf(n.charAt(p)));
            ans += a[p];
        }
        if(ans % 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();
        long[] a = new long[n.length()];
        int ans = 0;
        for(int p = 0; p < n.length(); p++){
            a[p] = Long.parseLong(String.valueOf(n.charAt(p)));
            ans += a[p];
        }
        if(ans % 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();
        long[] a = new long[n.length()];
        int ans = 0;
        for(int p = 0; p < n.length(); p++){
            a[p] = Long.parseLong(String.valueOf(n.charAt(p)));
            ans += a[p];
        }
        if(ans % 9 == 0){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }

    }
}