import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		String N = scan.next();
		scan.close();
		String[] strarray = N.split("");


		int[] num = new int[strarray.length];
		int sum = 0;
		for(int i = 0; i < strarray.length; i++) {

			num[i] = Integer.parseInt(strarray[i]);
			sum = sum + num[i];

		}

		if(sum % 9 == 0) {
			System.out.println("Yes");
		}else if(sum % 9 != 0) {
			System.out.println("No");
		}

	}

} import java.util.Scanner; Scanner java.util public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		String N = scan.next();
		scan.close();
		String[] strarray = N.split("");


		int[] num = new int[strarray.length];
		int sum = 0;
		for(int i = 0; i < strarray.length; i++) {

			num[i] = Integer.parseInt(strarray[i]);
			sum = sum + num[i];

		}

		if(sum % 9 == 0) {
			System.out.println("Yes");
		}else if(sum % 9 != 0) {
			System.out.println("No");
		}

	}

} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		String N = scan.next();
		scan.close();
		String[] strarray = N.split("");


		int[] num = new int[strarray.length];
		int sum = 0;
		for(int i = 0; i < strarray.length; i++) {

			num[i] = Integer.parseInt(strarray[i]);
			sum = sum + num[i];

		}

		if(sum % 9 == 0) {
			System.out.println("Yes");
		}else if(sum % 9 != 0) {
			System.out.println("No");
		}

	} main {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		String N = scan.next();
		scan.close();
		String[] strarray = N.split("");


		int[] num = new int[strarray.length];
		int sum = 0;
		for(int i = 0; i < strarray.length; i++) {

			num[i] = Integer.parseInt(strarray[i]);
			sum = sum + num[i];

		}

		if(sum % 9 == 0) {
			System.out.println("Yes");
		}else if(sum % 9 != 0) {
			System.out.println("No");
		}

	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String N = scan.next(); N scan.next() scan.next scan scan.close() scan.close scan String[] strarray = N.split(""); strarray N.split("") N.split N "" int[] num = new int[strarray.length]; num new int[strarray.length] strarray.length strarray strarray.length int sum = 0; sum 0 for(int i = 0; i < strarray.length; i++) {

			num[i] = Integer.parseInt(strarray[i]);
			sum = sum + num[i];

		} int i = 0; int i = 0; i 0 i < strarray.length i strarray.length strarray strarray.length i++ i++ i {

			num[i] = Integer.parseInt(strarray[i]);
			sum = sum + num[i];

		} {

			num[i] = Integer.parseInt(strarray[i]);
			sum = sum + num[i];

		} num[i] = Integer.parseInt(strarray[i]) num[i] num i Integer.parseInt(strarray[i]) Integer.parseInt Integer strarray[i] strarray i sum = sum + num[i] sum sum + num[i] sum num[i] num i if(sum % 9 == 0) {
			System.out.println("Yes");
		}else if(sum % 9 != 0) {
			System.out.println("No");
		} sum % 9 == 0 sum % 9 sum 9 0 {
			System.out.println("Yes");
		} System.out.println("Yes") System.out.println System.out System System.out "Yes" if(sum % 9 != 0) {
			System.out.println("No");
		} sum % 9 != 0 sum % 9 sum 9 0 {
			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) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		String N = scan.next();
		scan.close();
		String[] strarray = N.split("");


		int[] num = new int[strarray.length];
		int sum = 0;
		for(int i = 0; i < strarray.length; i++) {

			num[i] = Integer.parseInt(strarray[i]);
			sum = sum + num[i];

		}

		if(sum % 9 == 0) {
			System.out.println("Yes");
		}else if(sum % 9 != 0) {
			System.out.println("No");
		}

	}

} public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		String N = scan.next();
		scan.close();
		String[] strarray = N.split("");


		int[] num = new int[strarray.length];
		int sum = 0;
		for(int i = 0; i < strarray.length; i++) {

			num[i] = Integer.parseInt(strarray[i]);
			sum = sum + num[i];

		}

		if(sum % 9 == 0) {
			System.out.println("Yes");
		}else if(sum % 9 != 0) {
			System.out.println("No");
		}

	}

} Main
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		String N = scan.next();
		scan.close();
		String[] strarray = N.split("");


		int[] num = new int[strarray.length];
		int sum = 0;
		for(int i = 0; i < strarray.length; i++) {

			num[i] = Integer.parseInt(strarray[i]);
			sum = sum + num[i];

		}

		if(sum % 9 == 0) {
			System.out.println("Yes");
		}else if(sum % 9 != 0) {
			System.out.println("No");
		}

	}

}
