import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try (Scanner sc = new Scanner(System.in)) {
			char[] nums = sc.next().toCharArray();
			int sum = 0;

			int length = nums.length;
			for (int i = 0; i <length; i++) {
				sum += nums[i] - '0';
			}

			String ans = "No";
			if (sum % 9 == 0) {
				ans = "Yes";
			}

			System.out.println(ans);

		} catch (Exception e) {
			// TODO: handle exception
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try (Scanner sc = new Scanner(System.in)) {
			char[] nums = sc.next().toCharArray();
			int sum = 0;

			int length = nums.length;
			for (int i = 0; i <length; i++) {
				sum += nums[i] - '0';
			}

			String ans = "No";
			if (sum % 9 == 0) {
				ans = "Yes";
			}

			System.out.println(ans);

		} catch (Exception e) {
			// TODO: handle exception
		}
	}
} Main public static void main(String[] args) {
		// TODO Auto-generated method stub
		try (Scanner sc = new Scanner(System.in)) {
			char[] nums = sc.next().toCharArray();
			int sum = 0;

			int length = nums.length;
			for (int i = 0; i <length; i++) {
				sum += nums[i] - '0';
			}

			String ans = "No";
			if (sum % 9 == 0) {
				ans = "Yes";
			}

			System.out.println(ans);

		} catch (Exception e) {
			// TODO: handle exception
		}
	} main {
		// TODO Auto-generated method stub
		try (Scanner sc = new Scanner(System.in)) {
			char[] nums = sc.next().toCharArray();
			int sum = 0;

			int length = nums.length;
			for (int i = 0; i <length; i++) {
				sum += nums[i] - '0';
			}

			String ans = "No";
			if (sum % 9 == 0) {
				ans = "Yes";
			}

			System.out.println(ans);

		} catch (Exception e) {
			// TODO: handle exception
		}
	} try (Scanner sc = new Scanner(System.in)) {
			char[] nums = sc.next().toCharArray();
			int sum = 0;

			int length = nums.length;
			for (int i = 0; i <length; i++) {
				sum += nums[i] - '0';
			}

			String ans = "No";
			if (sum % 9 == 0) {
				ans = "Yes";
			}

			System.out.println(ans);

		} catch (Exception e) {
			// TODO: handle exception
		} catch (Exception e) {
			// TODO: handle exception
		} Exception e {
			// TODO: handle exception
		} {
			char[] nums = sc.next().toCharArray();
			int sum = 0;

			int length = nums.length;
			for (int i = 0; i <length; i++) {
				sum += nums[i] - '0';
			}

			String ans = "No";
			if (sum % 9 == 0) {
				ans = "Yes";
			}

			System.out.println(ans);

		} Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) char[] nums = sc.next().toCharArray(); nums sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc int sum = 0; sum 0 int length = nums.length; length nums.length nums nums.length for (int i = 0; i <length; i++) {
				sum += nums[i] - '0';
			} int i = 0; int i = 0; i 0 i <length i length i++ i++ i {
				sum += nums[i] - '0';
			} {
				sum += nums[i] - '0';
			} sum += nums[i] - '0' sum nums[i] - '0' nums[i] nums i '0' String ans = "No"; ans "No" if (sum % 9 == 0) {
				ans = "Yes";
			} sum % 9 == 0 sum % 9 sum 9 0 {
				ans = "Yes";
			} ans = "Yes" ans "Yes" System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try (Scanner sc = new Scanner(System.in)) {
			char[] nums = sc.next().toCharArray();
			int sum = 0;

			int length = nums.length;
			for (int i = 0; i <length; i++) {
				sum += nums[i] - '0';
			}

			String ans = "No";
			if (sum % 9 == 0) {
				ans = "Yes";
			}

			System.out.println(ans);

		} catch (Exception e) {
			// TODO: handle exception
		}
	}
} public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try (Scanner sc = new Scanner(System.in)) {
			char[] nums = sc.next().toCharArray();
			int sum = 0;

			int length = nums.length;
			for (int i = 0; i <length; i++) {
				sum += nums[i] - '0';
			}

			String ans = "No";
			if (sum % 9 == 0) {
				ans = "Yes";
			}

			System.out.println(ans);

		} catch (Exception e) {
			// TODO: handle exception
		}
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try (Scanner sc = new Scanner(System.in)) {
			char[] nums = sc.next().toCharArray();
			int sum = 0;

			int length = nums.length;
			for (int i = 0; i <length; i++) {
				sum += nums[i] - '0';
			}

			String ans = "No";
			if (sum % 9 == 0) {
				ans = "Yes";
			}

			System.out.println(ans);

		} catch (Exception e) {
			// TODO: handle exception
		}
	}
}
