
import java.util.Scanner;


public class Main {
	public static void main (String args[]) throws Exception{
		Scanner scan = new Scanner(System.in);
		String n = scan.next();
		int sum = 0;
		String ans = "No";
		
		for(int i = 0; i < n.length(); i++) {
			sum += Integer.parseInt(n.substring(i, i+1));
		}
		
		if(sum % 9 == 0 ) {
			ans = "Yes";
		}

		System.out.print(ans);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main (String args[]) throws Exception{
		Scanner scan = new Scanner(System.in);
		String n = scan.next();
		int sum = 0;
		String ans = "No";
		
		for(int i = 0; i < n.length(); i++) {
			sum += Integer.parseInt(n.substring(i, i+1));
		}
		
		if(sum % 9 == 0 ) {
			ans = "Yes";
		}

		System.out.print(ans);
	}
} Main public static void main (String args[]) throws Exception{
		Scanner scan = new Scanner(System.in);
		String n = scan.next();
		int sum = 0;
		String ans = "No";
		
		for(int i = 0; i < n.length(); i++) {
			sum += Integer.parseInt(n.substring(i, i+1));
		}
		
		if(sum % 9 == 0 ) {
			ans = "Yes";
		}

		System.out.print(ans);
	} main {
		Scanner scan = new Scanner(System.in);
		String n = scan.next();
		int sum = 0;
		String ans = "No";
		
		for(int i = 0; i < n.length(); i++) {
			sum += Integer.parseInt(n.substring(i, i+1));
		}
		
		if(sum % 9 == 0 ) {
			ans = "Yes";
		}

		System.out.print(ans);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String n = scan.next(); n scan.next() scan.next scan int sum = 0; sum 0 String ans = "No"; ans "No" for(int i = 0; i < n.length(); i++) {
			sum += Integer.parseInt(n.substring(i, i+1));
		} int i = 0; int i = 0; i 0 i < n.length() i n.length() n.length n i++ i++ i {
			sum += Integer.parseInt(n.substring(i, i+1));
		} {
			sum += Integer.parseInt(n.substring(i, i+1));
		} sum += Integer.parseInt(n.substring(i, i+1)) sum Integer.parseInt(n.substring(i, i+1)) Integer.parseInt Integer n.substring(i, i+1) n.substring n i i+1 i 1 if(sum % 9 == 0 ) {
			ans = "Yes";
		} sum % 9 == 0 sum % 9 sum 9 0 {
			ans = "Yes";
		} ans = "Yes" ans "Yes" System.out.print(ans) System.out.print System.out System System.out ans String args[] args public class Main {
	public static void main (String args[]) throws Exception{
		Scanner scan = new Scanner(System.in);
		String n = scan.next();
		int sum = 0;
		String ans = "No";
		
		for(int i = 0; i < n.length(); i++) {
			sum += Integer.parseInt(n.substring(i, i+1));
		}
		
		if(sum % 9 == 0 ) {
			ans = "Yes";
		}

		System.out.print(ans);
	}
} public class Main {
	public static void main (String args[]) throws Exception{
		Scanner scan = new Scanner(System.in);
		String n = scan.next();
		int sum = 0;
		String ans = "No";
		
		for(int i = 0; i < n.length(); i++) {
			sum += Integer.parseInt(n.substring(i, i+1));
		}
		
		if(sum % 9 == 0 ) {
			ans = "Yes";
		}

		System.out.print(ans);
	}
} Main

import java.util.Scanner;


public class Main {
	public static void main (String args[]) throws Exception{
		Scanner scan = new Scanner(System.in);
		String n = scan.next();
		int sum = 0;
		String ans = "No";
		
		for(int i = 0; i < n.length(); i++) {
			sum += Integer.parseInt(n.substring(i, i+1));
		}
		
		if(sum % 9 == 0 ) {
			ans = "Yes";
		}

		System.out.print(ans);
	}
}