
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        String N = scan.next();

        long sum = 0;
        for(int i = 0; i < N.length(); i++) {
            sum += Integer.valueOf(N.charAt(i)-'0');
        }

        if(sum % 9 == 0)
            os.println("Yes");
        else
            os.println("No");

    }
} import java.io.InputStream; InputStream java.io import java.io.PrintStream; PrintStream java.io import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        String N = scan.next();

        long sum = 0;
        for(int i = 0; i < N.length(); i++) {
            sum += Integer.valueOf(N.charAt(i)-'0');
        }

        if(sum % 9 == 0)
            os.println("Yes");
        else
            os.println("No");

    }
} Main public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    } main {
        solve(System.in, System.out);
    } solve(System.in, System.out) solve System.in System System.in System.out System System.out String[] args args static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        String N = scan.next();

        long sum = 0;
        for(int i = 0; i < N.length(); i++) {
            sum += Integer.valueOf(N.charAt(i)-'0');
        }

        if(sum % 9 == 0)
            os.println("Yes");
        else
            os.println("No");

    } solve {
        // Your code here!
        Scanner scan = new Scanner(is);
        String N = scan.next();

        long sum = 0;
        for(int i = 0; i < N.length(); i++) {
            sum += Integer.valueOf(N.charAt(i)-'0');
        }

        if(sum % 9 == 0)
            os.println("Yes");
        else
            os.println("No");

    } Scanner scan = new Scanner(is); scan new Scanner(is) String N = scan.next(); N scan.next() scan.next scan long sum = 0; sum 0 for(int i = 0; i < N.length(); i++) {
            sum += Integer.valueOf(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 += Integer.valueOf(N.charAt(i)-'0');
        } {
            sum += Integer.valueOf(N.charAt(i)-'0');
        } sum += Integer.valueOf(N.charAt(i)-'0') sum Integer.valueOf(N.charAt(i)-'0') Integer.valueOf Integer N.charAt(i)-'0' N.charAt(i) N.charAt N i '0' if(sum % 9 == 0)
            os.println("Yes");
        else
            os.println("No"); sum % 9 == 0 sum % 9 sum 9 0 os.println("Yes") os.println os "Yes" os.println("No") os.println os "No" InputStream is is PrintStream os os public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        String N = scan.next();

        long sum = 0;
        for(int i = 0; i < N.length(); i++) {
            sum += Integer.valueOf(N.charAt(i)-'0');
        }

        if(sum % 9 == 0)
            os.println("Yes");
        else
            os.println("No");

    }
} public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        String N = scan.next();

        long sum = 0;
        for(int i = 0; i < N.length(); i++) {
            sum += Integer.valueOf(N.charAt(i)-'0');
        }

        if(sum % 9 == 0)
            os.println("Yes");
        else
            os.println("No");

    }
} Main

import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        String N = scan.next();

        long sum = 0;
        for(int i = 0; i < N.length(); i++) {
            sum += Integer.valueOf(N.charAt(i)-'0');
        }

        if(sum % 9 == 0)
            os.println("Yes");
        else
            os.println("No");

    }
}