import java.util.*;
import java.io.*;
class Main{
	public static void main(String[]args){
		Scanner in=new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out, true);
		String str = in.nextLine();
		int sum = 0;
		for(int i=0;i<str.length();i++){
			sum += str.charAt(i) - '0';
		}
		if(sum%9 == 0)
			out.println("Yes");
		else
			out.println("No");
	}
} import java.util.*; util.* java import java.io.*; io.* java class Main{
	public static void main(String[]args){
		Scanner in=new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out, true);
		String str = in.nextLine();
		int sum = 0;
		for(int i=0;i<str.length();i++){
			sum += str.charAt(i) - '0';
		}
		if(sum%9 == 0)
			out.println("Yes");
		else
			out.println("No");
	}
} Main public static void main(String[]args){
		Scanner in=new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out, true);
		String str = in.nextLine();
		int sum = 0;
		for(int i=0;i<str.length();i++){
			sum += str.charAt(i) - '0';
		}
		if(sum%9 == 0)
			out.println("Yes");
		else
			out.println("No");
	} main {
		Scanner in=new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out, true);
		String str = in.nextLine();
		int sum = 0;
		for(int i=0;i<str.length();i++){
			sum += str.charAt(i) - '0';
		}
		if(sum%9 == 0)
			out.println("Yes");
		else
			out.println("No");
	} Scanner in=new Scanner(System.in); in new Scanner(System.in) PrintWriter out = new PrintWriter(System.out, true); out new PrintWriter(System.out, true) String str = in.nextLine(); str in.nextLine() in.nextLine in int sum = 0; sum 0 for(int i=0;i<str.length();i++){
			sum += str.charAt(i) - '0';
		} int i=0; int i=0; i 0 i<str.length() i str.length() str.length str i++ i++ i {
			sum += str.charAt(i) - '0';
		} {
			sum += str.charAt(i) - '0';
		} sum += str.charAt(i) - '0' sum str.charAt(i) - '0' str.charAt(i) str.charAt str i '0' if(sum%9 == 0)
			out.println("Yes");
		else
			out.println("No"); sum%9 == 0 sum%9 sum 9 0 out.println("Yes") out.println out "Yes" out.println("No") out.println out "No" String[]args args
import java.util.*;
import java.io.*;
class Main{
	public static void main(String[]args){
		Scanner in=new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out, true);
		String str = in.nextLine();
		int sum = 0;
		for(int i=0;i<str.length();i++){
			sum += str.charAt(i) - '0';
		}
		if(sum%9 == 0)
			out.println("Yes");
		else
			out.println("No");
	}
}
