import java.util.*;
public class Main {
	public static void main(String[] args){
    
		Scanner sc = new Scanner(System.in);
		// 整数の入力
	
		// 文字列の入力
		String n = sc.next();
    
    /*--------------------------------*/
    //入力
    //String n = "123456789";
		String buf = "";

		//配列に格納
		int x = 0;
		for(int i= 0; i<n.length();i++){
		 buf=n.substring(i,i+1);
		 x += Integer.parseInt(buf);
		 //System.out.println(x);
		}

		//answer
		if(x%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 n = sc.next();
    
    /*--------------------------------*/
    //入力
    //String n = "123456789";
		String buf = "";

		//配列に格納
		int x = 0;
		for(int i= 0; i<n.length();i++){
		 buf=n.substring(i,i+1);
		 x += Integer.parseInt(buf);
		 //System.out.println(x);
		}

		//answer
		if(x%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 n = sc.next();
    
    /*--------------------------------*/
    //入力
    //String n = "123456789";
		String buf = "";

		//配列に格納
		int x = 0;
		for(int i= 0; i<n.length();i++){
		 buf=n.substring(i,i+1);
		 x += Integer.parseInt(buf);
		 //System.out.println(x);
		}

		//answer
		if(x%9 == 0){
			System.out.println("Yes");
		}else{
				System.out.println("No");
		}

	} main {
    
		Scanner sc = new Scanner(System.in);
		// 整数の入力
	
		// 文字列の入力
		String n = sc.next();
    
    /*--------------------------------*/
    //入力
    //String n = "123456789";
		String buf = "";

		//配列に格納
		int x = 0;
		for(int i= 0; i<n.length();i++){
		 buf=n.substring(i,i+1);
		 x += Integer.parseInt(buf);
		 //System.out.println(x);
		}

		//answer
		if(x%9 == 0){
			System.out.println("Yes");
		}else{
				System.out.println("No");
		}

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String n = sc.next(); n sc.next() sc.next sc String buf = ""; buf "" int x = 0; x 0 for(int i= 0; i<n.length();i++){
		 buf=n.substring(i,i+1);
		 x += Integer.parseInt(buf);
		 //System.out.println(x);
		} int i= 0; int i= 0; i 0 i<n.length() i n.length() n.length n i++ i++ i {
		 buf=n.substring(i,i+1);
		 x += Integer.parseInt(buf);
		 //System.out.println(x);
		} {
		 buf=n.substring(i,i+1);
		 x += Integer.parseInt(buf);
		 //System.out.println(x);
		} buf=n.substring(i,i+1) buf n.substring(i,i+1) n.substring n i i+1 i 1 x += Integer.parseInt(buf) x Integer.parseInt(buf) Integer.parseInt Integer buf if(x%9 == 0){
			System.out.println("Yes");
		}else{
				System.out.println("No");
		} x%9 == 0 x%9 x 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 n = sc.next();
    
    /*--------------------------------*/
    //入力
    //String n = "123456789";
		String buf = "";

		//配列に格納
		int x = 0;
		for(int i= 0; i<n.length();i++){
		 buf=n.substring(i,i+1);
		 x += Integer.parseInt(buf);
		 //System.out.println(x);
		}

		//answer
		if(x%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 n = sc.next();
    
    /*--------------------------------*/
    //入力
    //String n = "123456789";
		String buf = "";

		//配列に格納
		int x = 0;
		for(int i= 0; i<n.length();i++){
		 buf=n.substring(i,i+1);
		 x += Integer.parseInt(buf);
		 //System.out.println(x);
		}

		//answer
		if(x%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 n = sc.next();
    
    /*--------------------------------*/
    //入力
    //String n = "123456789";
		String buf = "";

		//配列に格納
		int x = 0;
		for(int i= 0; i<n.length();i++){
		 buf=n.substring(i,i+1);
		 x += Integer.parseInt(buf);
		 //System.out.println(x);
		}

		//answer
		if(x%9 == 0){
			System.out.println("Yes");
		}else{
				System.out.println("No");
		}

	}
}

