import java.util.*;
import java.io.*;

public class Main {
    static StringBuilder sb;

    public static void solve(String n) {
        long sum = 0;
        for (int i = 0; i < n.length(); i++) {
            sum += n.charAt(i) - '0';
        }
        if (sum % 9 == 0) sb.append("Yes");
        else sb.append("No");
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        sb = new StringBuilder();

        String n = sc.next();

        solve(n);

        pw.print(sb);
        pw.flush();
        sc.close();
    }
} import java.util.*; util.* java import java.io.*; io.* java public class Main {
    static StringBuilder sb;

    public static void solve(String n) {
        long sum = 0;
        for (int i = 0; i < n.length(); i++) {
            sum += n.charAt(i) - '0';
        }
        if (sum % 9 == 0) sb.append("Yes");
        else sb.append("No");
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        sb = new StringBuilder();

        String n = sc.next();

        solve(n);

        pw.print(sb);
        pw.flush();
        sc.close();
    }
} Main static StringBuilder sb; sb public static void solve(String n) {
        long sum = 0;
        for (int i = 0; i < n.length(); i++) {
            sum += n.charAt(i) - '0';
        }
        if (sum % 9 == 0) sb.append("Yes");
        else sb.append("No");
    } solve {
        long sum = 0;
        for (int i = 0; i < n.length(); i++) {
            sum += n.charAt(i) - '0';
        }
        if (sum % 9 == 0) sb.append("Yes");
        else sb.append("No");
    } long sum = 0; sum 0 for (int i = 0; i < n.length(); i++) {
            sum += n.charAt(i) - '0';
        } int i = 0; int i = 0; i 0 i < n.length() i n.length() n.length n i++ i++ i {
            sum += n.charAt(i) - '0';
        } {
            sum += n.charAt(i) - '0';
        } sum += n.charAt(i) - '0' sum n.charAt(i) - '0' n.charAt(i) n.charAt n i '0' if (sum % 9 == 0) sb.append("Yes");
        else sb.append("No"); sum % 9 == 0 sum % 9 sum 9 0 sb.append("Yes") sb.append sb "Yes" sb.append("No") sb.append sb "No" String n n public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        sb = new StringBuilder();

        String n = sc.next();

        solve(n);

        pw.print(sb);
        pw.flush();
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        sb = new StringBuilder();

        String n = sc.next();

        solve(n);

        pw.print(sb);
        pw.flush();
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) PrintWriter pw = new PrintWriter(System.out); pw new PrintWriter(System.out) sb = new StringBuilder() sb new StringBuilder() String n = sc.next(); n sc.next() sc.next sc solve(n) solve n pw.print(sb) pw.print pw sb pw.flush() pw.flush pw sc.close() sc.close sc String[] args args public class Main {
    static StringBuilder sb;

    public static void solve(String n) {
        long sum = 0;
        for (int i = 0; i < n.length(); i++) {
            sum += n.charAt(i) - '0';
        }
        if (sum % 9 == 0) sb.append("Yes");
        else sb.append("No");
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        sb = new StringBuilder();

        String n = sc.next();

        solve(n);

        pw.print(sb);
        pw.flush();
        sc.close();
    }
} public class Main {
    static StringBuilder sb;

    public static void solve(String n) {
        long sum = 0;
        for (int i = 0; i < n.length(); i++) {
            sum += n.charAt(i) - '0';
        }
        if (sum % 9 == 0) sb.append("Yes");
        else sb.append("No");
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        sb = new StringBuilder();

        String n = sc.next();

        solve(n);

        pw.print(sb);
        pw.flush();
        sc.close();
    }
} Main
import java.util.*;
import java.io.*;

public class Main {
    static StringBuilder sb;

    public static void solve(String n) {
        long sum = 0;
        for (int i = 0; i < n.length(); i++) {
            sum += n.charAt(i) - '0';
        }
        if (sum % 9 == 0) sb.append("Yes");
        else sb.append("No");
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        sb = new StringBuilder();

        String n = sc.next();

        solve(n);

        pw.print(sb);
        pw.flush();
        sc.close();
    }
}