//package beginner176;

import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner in = new Scanner(System.in);

        String s = in.next();

        int cnt = 0;
        int len = s.length();
        for(int i = 0; i < len; i++){
            cnt += s.charAt(i) - '0';
        }
        if(cnt % 3 == 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args){
        Scanner in = new Scanner(System.in);

        String s = in.next();

        int cnt = 0;
        int len = s.length();
        for(int i = 0; i < len; i++){
            cnt += s.charAt(i) - '0';
        }
        if(cnt % 3 == 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
} Main public static void main(String[] args){
        Scanner in = new Scanner(System.in);

        String s = in.next();

        int cnt = 0;
        int len = s.length();
        for(int i = 0; i < len; i++){
            cnt += s.charAt(i) - '0';
        }
        if(cnt % 3 == 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    } main {
        Scanner in = new Scanner(System.in);

        String s = in.next();

        int cnt = 0;
        int len = s.length();
        for(int i = 0; i < len; i++){
            cnt += s.charAt(i) - '0';
        }
        if(cnt % 3 == 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    } Scanner in = new Scanner(System.in); in new Scanner(System.in) String s = in.next(); s in.next() in.next in int cnt = 0; cnt 0 int len = s.length(); len s.length() s.length s for(int i = 0; i < len; i++){
            cnt += s.charAt(i) - '0';
        } int i = 0; int i = 0; i 0 i < len i len i++ i++ i {
            cnt += s.charAt(i) - '0';
        } {
            cnt += s.charAt(i) - '0';
        } cnt += s.charAt(i) - '0' cnt s.charAt(i) - '0' s.charAt(i) s.charAt s i '0' if(cnt % 3 == 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        } cnt % 3 == 0 cnt % 3 cnt 3 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 in = new Scanner(System.in);

        String s = in.next();

        int cnt = 0;
        int len = s.length();
        for(int i = 0; i < len; i++){
            cnt += s.charAt(i) - '0';
        }
        if(cnt % 3 == 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
} public class Main {

    public static void main(String[] args){
        Scanner in = new Scanner(System.in);

        String s = in.next();

        int cnt = 0;
        int len = s.length();
        for(int i = 0; i < len; i++){
            cnt += s.charAt(i) - '0';
        }
        if(cnt % 3 == 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
} Main
//package beginner176;

import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner in = new Scanner(System.in);

        String s = in.next();

        int cnt = 0;
        int len = s.length();
        for(int i = 0; i < len; i++){
            cnt += s.charAt(i) - '0';
        }
        if(cnt % 3 == 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}
