
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		int count = 0;

		for (int i = 1; i <= n.length(); i++) {
			count += Integer.parseInt(n.substring(i-1, i));
		}

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

		sc.close();
	}

} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		int count = 0;

		for (int i = 1; i <= n.length(); i++) {
			count += Integer.parseInt(n.substring(i-1, i));
		}

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

		sc.close();
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		int count = 0;

		for (int i = 1; i <= n.length(); i++) {
			count += Integer.parseInt(n.substring(i-1, i));
		}

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

		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		int count = 0;

		for (int i = 1; i <= n.length(); i++) {
			count += Integer.parseInt(n.substring(i-1, i));
		}

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

		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String n = sc.next(); n sc.next() sc.next sc int count = 0; count 0 for (int i = 1; i <= n.length(); i++) {
			count += Integer.parseInt(n.substring(i-1, i));
		} int i = 1; int i = 1; i 1 i <= n.length() i n.length() n.length n i++ i++ i {
			count += Integer.parseInt(n.substring(i-1, i));
		} {
			count += Integer.parseInt(n.substring(i-1, i));
		} count += Integer.parseInt(n.substring(i-1, i)) count Integer.parseInt(n.substring(i-1, i)) Integer.parseInt Integer n.substring(i-1, i) n.substring n i-1 i 1 i if (count % 9 == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		} count % 9 == 0 count % 9 count 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("No") System.out.println System.out System System.out "No" sc.close() sc.close sc String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		int count = 0;

		for (int i = 1; i <= n.length(); i++) {
			count += Integer.parseInt(n.substring(i-1, i));
		}

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

		sc.close();
	}

} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		int count = 0;

		for (int i = 1; i <= n.length(); i++) {
			count += Integer.parseInt(n.substring(i-1, i));
		}

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

		sc.close();
	}

} Main

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		int count = 0;

		for (int i = 1; i <= n.length(); i++) {
			count += Integer.parseInt(n.substring(i-1, i));
		}

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

		sc.close();
	}

}