import java.util.Scanner;

 
public class Main {
 
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		char[] n  = sc.nextLine().toCharArray();
		String ans = "No";
		long culc = 0;

		for(char num : n) {
			culc += Integer.parseInt(String.valueOf(num));
		}
		
		if(culc % 9 == 0) {
			ans = "Yes";
		}
		
		System.out.println(ans);
		sc.close();
	}
}

 import java.util.Scanner; Scanner java.util public class Main {
 
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		char[] n  = sc.nextLine().toCharArray();
		String ans = "No";
		long culc = 0;

		for(char num : n) {
			culc += Integer.parseInt(String.valueOf(num));
		}
		
		if(culc % 9 == 0) {
			ans = "Yes";
		}
		
		System.out.println(ans);
		sc.close();
	}
} Main public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		char[] n  = sc.nextLine().toCharArray();
		String ans = "No";
		long culc = 0;

		for(char num : n) {
			culc += Integer.parseInt(String.valueOf(num));
		}
		
		if(culc % 9 == 0) {
			ans = "Yes";
		}
		
		System.out.println(ans);
		sc.close();
	} main {
		
		Scanner sc = new Scanner(System.in);
		char[] n  = sc.nextLine().toCharArray();
		String ans = "No";
		long culc = 0;

		for(char num : n) {
			culc += Integer.parseInt(String.valueOf(num));
		}
		
		if(culc % 9 == 0) {
			ans = "Yes";
		}
		
		System.out.println(ans);
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) char[] n  = sc.nextLine().toCharArray(); n sc.nextLine().toCharArray() sc.nextLine().toCharArray sc.nextLine() sc.nextLine sc String ans = "No"; ans "No" long culc = 0; culc 0 for(char num : n) {
			culc += Integer.parseInt(String.valueOf(num));
		} char num n {
			culc += Integer.parseInt(String.valueOf(num));
		} {
			culc += Integer.parseInt(String.valueOf(num));
		} culc += Integer.parseInt(String.valueOf(num)) culc Integer.parseInt(String.valueOf(num)) Integer.parseInt Integer String.valueOf(num) String.valueOf String num if(culc % 9 == 0) {
			ans = "Yes";
		} culc % 9 == 0 culc % 9 culc 9 0 {
			ans = "Yes";
		} ans = "Yes" ans "Yes" System.out.println(ans) System.out.println System.out System System.out ans sc.close() sc.close sc String[] args args public class Main {
 
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		char[] n  = sc.nextLine().toCharArray();
		String ans = "No";
		long culc = 0;

		for(char num : n) {
			culc += Integer.parseInt(String.valueOf(num));
		}
		
		if(culc % 9 == 0) {
			ans = "Yes";
		}
		
		System.out.println(ans);
		sc.close();
	}
} public class Main {
 
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		char[] n  = sc.nextLine().toCharArray();
		String ans = "No";
		long culc = 0;

		for(char num : n) {
			culc += Integer.parseInt(String.valueOf(num));
		}
		
		if(culc % 9 == 0) {
			ans = "Yes";
		}
		
		System.out.println(ans);
		sc.close();
	}
} Main
import java.util.Scanner;

 
public class Main {
 
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		char[] n  = sc.nextLine().toCharArray();
		String ans = "No";
		long culc = 0;

		for(char num : n) {
			culc += Integer.parseInt(String.valueOf(num));
		}
		
		if(culc % 9 == 0) {
			ans = "Yes";
		}
		
		System.out.println(ans);
		sc.close();
	}
}


