import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[]args){
	int ans=0;
        Scanner sc = new Scanner(System.in);
        String N=sc.next();
	int sum=0;
	for(int i=0; i<N.length(); i++){
	    sum+=Integer.parseInt(N.substring(i,i+1));
	}
	//N.charAt(i)
        if(sum%9==0){
	    System.out.println("Yes");
	}else{
	    System.out.println("No");
	}
    }
} import java.util.*; util.* java import java.lang.*; lang.* java public class Main{
    public static void main(String[]args){
	int ans=0;
        Scanner sc = new Scanner(System.in);
        String N=sc.next();
	int sum=0;
	for(int i=0; i<N.length(); i++){
	    sum+=Integer.parseInt(N.substring(i,i+1));
	}
	//N.charAt(i)
        if(sum%9==0){
	    System.out.println("Yes");
	}else{
	    System.out.println("No");
	}
    }
} Main public static void main(String[]args){
	int ans=0;
        Scanner sc = new Scanner(System.in);
        String N=sc.next();
	int sum=0;
	for(int i=0; i<N.length(); i++){
	    sum+=Integer.parseInt(N.substring(i,i+1));
	}
	//N.charAt(i)
        if(sum%9==0){
	    System.out.println("Yes");
	}else{
	    System.out.println("No");
	}
    } main {
	int ans=0;
        Scanner sc = new Scanner(System.in);
        String N=sc.next();
	int sum=0;
	for(int i=0; i<N.length(); i++){
	    sum+=Integer.parseInt(N.substring(i,i+1));
	}
	//N.charAt(i)
        if(sum%9==0){
	    System.out.println("Yes");
	}else{
	    System.out.println("No");
	}
    } int ans=0; ans 0 Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String N=sc.next(); N sc.next() sc.next sc int sum=0; sum 0 for(int i=0; i<N.length(); i++){
	    sum+=Integer.parseInt(N.substring(i,i+1));
	} int i=0; int i=0; i 0 i<N.length() i N.length() N.length N i++ i++ i {
	    sum+=Integer.parseInt(N.substring(i,i+1));
	} {
	    sum+=Integer.parseInt(N.substring(i,i+1));
	} sum+=Integer.parseInt(N.substring(i,i+1)) sum Integer.parseInt(N.substring(i,i+1)) Integer.parseInt Integer N.substring(i,i+1) N.substring N i i+1 i 1 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){
	int ans=0;
        Scanner sc = new Scanner(System.in);
        String N=sc.next();
	int sum=0;
	for(int i=0; i<N.length(); i++){
	    sum+=Integer.parseInt(N.substring(i,i+1));
	}
	//N.charAt(i)
        if(sum%9==0){
	    System.out.println("Yes");
	}else{
	    System.out.println("No");
	}
    }
} public class Main{
    public static void main(String[]args){
	int ans=0;
        Scanner sc = new Scanner(System.in);
        String N=sc.next();
	int sum=0;
	for(int i=0; i<N.length(); i++){
	    sum+=Integer.parseInt(N.substring(i,i+1));
	}
	//N.charAt(i)
        if(sum%9==0){
	    System.out.println("Yes");
	}else{
	    System.out.println("No");
	}
    }
} Main
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[]args){
	int ans=0;
        Scanner sc = new Scanner(System.in);
        String N=sc.next();
	int sum=0;
	for(int i=0; i<N.length(); i++){
	    sum+=Integer.parseInt(N.substring(i,i+1));
	}
	//N.charAt(i)
        if(sum%9==0){
	    System.out.println("Yes");
	}else{
	    System.out.println("No");
	}
    }
}
