import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        long n=0;
        long sum=0;
        while (n<s.length()){
            int num=Integer.parseInt(String.valueOf(s.charAt((int) n)));
            sum=sum+num;
            n++;
        }
        if (sum%9==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 sc=new Scanner(System.in);
        String s=sc.next();
        long n=0;
        long sum=0;
        while (n<s.length()){
            int num=Integer.parseInt(String.valueOf(s.charAt((int) n)));
            sum=sum+num;
            n++;
        }
        if (sum%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 s=sc.next();
        long n=0;
        long sum=0;
        while (n<s.length()){
            int num=Integer.parseInt(String.valueOf(s.charAt((int) n)));
            sum=sum+num;
            n++;
        }
        if (sum%9==0){
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    } main {
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        long n=0;
        long sum=0;
        while (n<s.length()){
            int num=Integer.parseInt(String.valueOf(s.charAt((int) n)));
            sum=sum+num;
            n++;
        }
        if (sum%9==0){
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    } Scanner sc=new Scanner(System.in); sc new Scanner(System.in) String s=sc.next(); s sc.next() sc.next sc long n=0; n 0 long sum=0; sum 0 while (n<s.length()){
            int num=Integer.parseInt(String.valueOf(s.charAt((int) n)));
            sum=sum+num;
            n++;
        } n<s.length() n s.length() s.length s {
            int num=Integer.parseInt(String.valueOf(s.charAt((int) n)));
            sum=sum+num;
            n++;
        } int num=Integer.parseInt(String.valueOf(s.charAt((int) n))); num Integer.parseInt(String.valueOf(s.charAt((int) n))) Integer.parseInt Integer String.valueOf(s.charAt((int) n)) String.valueOf String s.charAt((int) n) s.charAt s (int) n sum=sum+num sum sum+num sum num n++ n if (sum%9==0){
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        } sum%9==0 sum%9 sum 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 s=sc.next();
        long n=0;
        long sum=0;
        while (n<s.length()){
            int num=Integer.parseInt(String.valueOf(s.charAt((int) n)));
            sum=sum+num;
            n++;
        }
        if (sum%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 s=sc.next();
        long n=0;
        long sum=0;
        while (n<s.length()){
            int num=Integer.parseInt(String.valueOf(s.charAt((int) n)));
            sum=sum+num;
            n++;
        }
        if (sum%9==0){
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        long n=0;
        long sum=0;
        while (n<s.length()){
            int num=Integer.parseInt(String.valueOf(s.charAt((int) n)));
            sum=sum+num;
            n++;
        }
        if (sum%9==0){
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
}