import java.util.*;
class Main {
 
	//最大公約数・最小公倍数（セットで使う）
static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
static int lcm (int a, int b) {return a*b/gcd(a,b);}
   //整数かどうかを判定する
 static boolean isInteger(double number){return Math.ceil(number) == Math.floor(number); }

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
 
		String s = sc.next();
		char[] c = s.toCharArray();

		Long ans = 0l;
		for(int i=0;i<s.length();i++){
			ans += s.charAt(i) - '0';
		}
		
		if(ans%9 == 0){
			System.out.println("Yes");
		} else System.out.println("No");
	}
} import java.util.*; util.* java class Main {
 
	//最大公約数・最小公倍数（セットで使う）
static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
static int lcm (int a, int b) {return a*b/gcd(a,b);}
   //整数かどうかを判定する
 static boolean isInteger(double number){return Math.ceil(number) == Math.floor(number); }

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
 
		String s = sc.next();
		char[] c = s.toCharArray();

		Long ans = 0l;
		for(int i=0;i<s.length();i++){
			ans += s.charAt(i) - '0';
		}
		
		if(ans%9 == 0){
			System.out.println("Yes");
		} else System.out.println("No");
	}
} Main //最大公約数・最小公倍数（セットで使う）
static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;} gcd {return b>0?gcd(b,a%b):a;} return b>0?gcd(b,a%b):a; b>0?gcd(b,a%b):a b>0 b 0 gcd(b,a%b) gcd b a%b a b a int a a int b b static int lcm (int a, int b) {return a*b/gcd(a,b);} lcm {return a*b/gcd(a,b);} return a*b/gcd(a,b); a*b/gcd(a,b) a*b a b gcd(a,b) gcd a b int a a int b b //整数かどうかを判定する
 static boolean isInteger(double number){return Math.ceil(number) == Math.floor(number); } isInteger {return Math.ceil(number) == Math.floor(number); } return Math.ceil(number) == Math.floor(number); Math.ceil(number) == Math.floor(number) Math.ceil(number) Math.ceil Math number Math.floor(number) Math.floor Math number double number number public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
 
		String s = sc.next();
		char[] c = s.toCharArray();

		Long ans = 0l;
		for(int i=0;i<s.length();i++){
			ans += s.charAt(i) - '0';
		}
		
		if(ans%9 == 0){
			System.out.println("Yes");
		} else System.out.println("No");
	} main {
		Scanner sc = new Scanner(System.in);
 
		String s = sc.next();
		char[] c = s.toCharArray();

		Long ans = 0l;
		for(int i=0;i<s.length();i++){
			ans += s.charAt(i) - '0';
		}
		
		if(ans%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 char[] c = s.toCharArray(); c s.toCharArray() s.toCharArray s Long ans = 0l; ans 0l for(int i=0;i<s.length();i++){
			ans += s.charAt(i) - '0';
		} int i=0; int i=0; i 0 i<s.length() i s.length() s.length s i++ i++ i {
			ans += s.charAt(i) - '0';
		} {
			ans += s.charAt(i) - '0';
		} ans += s.charAt(i) - '0' ans s.charAt(i) - '0' s.charAt(i) s.charAt s i '0' if(ans%9 == 0){
			System.out.println("Yes");
		} else System.out.println("No"); ans%9 == 0 ans%9 ans 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 System.out System System.out "No" String[] args args
import java.util.*;
class Main {
 
	//最大公約数・最小公倍数（セットで使う）
static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
static int lcm (int a, int b) {return a*b/gcd(a,b);}
   //整数かどうかを判定する
 static boolean isInteger(double number){return Math.ceil(number) == Math.floor(number); }

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
 
		String s = sc.next();
		char[] c = s.toCharArray();

		Long ans = 0l;
		for(int i=0;i<s.length();i++){
			ans += s.charAt(i) - '0';
		}
		
		if(ans%9 == 0){
			System.out.println("Yes");
		} else System.out.println("No");
	}
}