import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    void solve(Scanner sc, PrintWriter pw) {
        String s = sc.next();
        int total = 0;
        for (int i = 0; i < s.length(); i++) {
            total += (s.charAt(i) - '0');
        }
        String result = (total % 9) == 0? "Yes" : "No";
        pw.println(result);
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        new Main().solve(sc, pw);
        pw.flush();
        pw.close();
        sc.close();
    }
} import java.io.PrintWriter; PrintWriter java.io import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
    void solve(Scanner sc, PrintWriter pw) {
        String s = sc.next();
        int total = 0;
        for (int i = 0; i < s.length(); i++) {
            total += (s.charAt(i) - '0');
        }
        String result = (total % 9) == 0? "Yes" : "No";
        pw.println(result);
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        new Main().solve(sc, pw);
        pw.flush();
        pw.close();
        sc.close();
    }
} Main void solve(Scanner sc, PrintWriter pw) {
        String s = sc.next();
        int total = 0;
        for (int i = 0; i < s.length(); i++) {
            total += (s.charAt(i) - '0');
        }
        String result = (total % 9) == 0? "Yes" : "No";
        pw.println(result);
    } solve {
        String s = sc.next();
        int total = 0;
        for (int i = 0; i < s.length(); i++) {
            total += (s.charAt(i) - '0');
        }
        String result = (total % 9) == 0? "Yes" : "No";
        pw.println(result);
    } String s = sc.next(); s sc.next() sc.next sc int total = 0; total 0 for (int i = 0; i < s.length(); i++) {
            total += (s.charAt(i) - '0');
        } int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
            total += (s.charAt(i) - '0');
        } {
            total += (s.charAt(i) - '0');
        } total += (s.charAt(i) - '0') total (s.charAt(i) - '0') s.charAt(i) s.charAt s i '0' String result = (total % 9) == 0? "Yes" : "No"; result (total % 9) == 0? "Yes" : "No" (total % 9) == 0 (total % 9) total 9 0 "Yes" "No" pw.println(result) pw.println pw result Scanner sc sc PrintWriter pw pw public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        new Main().solve(sc, pw);
        pw.flush();
        pw.close();
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        new Main().solve(sc, pw);
        pw.flush();
        pw.close();
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) PrintWriter pw = new PrintWriter(System.out); pw new PrintWriter(System.out) new Main().solve(sc, pw) new Main().solve new Main() sc pw pw.flush() pw.flush pw pw.close() pw.close pw sc.close() sc.close sc String[] args args public class Main {
    void solve(Scanner sc, PrintWriter pw) {
        String s = sc.next();
        int total = 0;
        for (int i = 0; i < s.length(); i++) {
            total += (s.charAt(i) - '0');
        }
        String result = (total % 9) == 0? "Yes" : "No";
        pw.println(result);
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        new Main().solve(sc, pw);
        pw.flush();
        pw.close();
        sc.close();
    }
} public class Main {
    void solve(Scanner sc, PrintWriter pw) {
        String s = sc.next();
        int total = 0;
        for (int i = 0; i < s.length(); i++) {
            total += (s.charAt(i) - '0');
        }
        String result = (total % 9) == 0? "Yes" : "No";
        pw.println(result);
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        new Main().solve(sc, pw);
        pw.flush();
        pw.close();
        sc.close();
    }
} Main
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    void solve(Scanner sc, PrintWriter pw) {
        String s = sc.next();
        int total = 0;
        for (int i = 0; i < s.length(); i++) {
            total += (s.charAt(i) - '0');
        }
        String result = (total % 9) == 0? "Yes" : "No";
        pw.println(result);
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        new Main().solve(sc, pw);
        pw.flush();
        pw.close();
        sc.close();
    }
}
