import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String S=sc.next();
		int tmp=0;
      	String ttt;
		for(int i=1;i<9;i++){
          	ttt = String.valueOf(i);;
			tmp+=i*(S.length() - S.replace(ttt,"").length());
		}
		if(tmp%9==0){
			System.out.println("Yes");
        }else{
			System.out.println("No");
		}
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String S=sc.next();
		int tmp=0;
      	String ttt;
		for(int i=1;i<9;i++){
          	ttt = String.valueOf(i);;
			tmp+=i*(S.length() - S.replace(ttt,"").length());
		}
		if(tmp%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();
		int tmp=0;
      	String ttt;
		for(int i=1;i<9;i++){
          	ttt = String.valueOf(i);;
			tmp+=i*(S.length() - S.replace(ttt,"").length());
		}
		if(tmp%9==0){
			System.out.println("Yes");
        }else{
			System.out.println("No");
		}
	} main {
		Scanner sc = new Scanner(System.in);
		String S=sc.next();
		int tmp=0;
      	String ttt;
		for(int i=1;i<9;i++){
          	ttt = String.valueOf(i);;
			tmp+=i*(S.length() - S.replace(ttt,"").length());
		}
		if(tmp%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 int tmp=0; tmp 0 String ttt; ttt for(int i=1;i<9;i++){
          	ttt = String.valueOf(i);;
			tmp+=i*(S.length() - S.replace(ttt,"").length());
		} int i=1; int i=1; i 1 i<9 i 9 i++ i++ i {
          	ttt = String.valueOf(i);;
			tmp+=i*(S.length() - S.replace(ttt,"").length());
		} {
          	ttt = String.valueOf(i);;
			tmp+=i*(S.length() - S.replace(ttt,"").length());
		} ttt = String.valueOf(i) ttt String.valueOf(i) String.valueOf String i tmp+=i*(S.length() - S.replace(ttt,"").length()) tmp i*(S.length() - S.replace(ttt,"").length()) i (S.length() - S.replace(ttt,"").length()) S.length() S.length S S.replace(ttt,"").length() S.replace(ttt,"").length S.replace(ttt,"") S.replace S ttt "" if(tmp%9==0){
			System.out.println("Yes");
        }else{
			System.out.println("No");
		} tmp%9==0 tmp%9 tmp 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();
		int tmp=0;
      	String ttt;
		for(int i=1;i<9;i++){
          	ttt = String.valueOf(i);;
			tmp+=i*(S.length() - S.replace(ttt,"").length());
		}
		if(tmp%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();
		int tmp=0;
      	String ttt;
		for(int i=1;i<9;i++){
          	ttt = String.valueOf(i);;
			tmp+=i*(S.length() - S.replace(ttt,"").length());
		}
		if(tmp%9==0){
			System.out.println("Yes");
        }else{
			System.out.println("No");
		}
	}
} Main
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String S=sc.next();
		int tmp=0;
      	String ttt;
		for(int i=1;i<9;i++){
          	ttt = String.valueOf(i);;
			tmp+=i*(S.length() - S.replace(ttt,"").length());
		}
		if(tmp%9==0){
			System.out.println("Yes");
        }else{
			System.out.println("No");
		}
	}
}