import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		BigDecimal n = sc.nextBigDecimal();
		if (n == BigDecimal.ZERO) {
			System.out.println("Yes");
			return;
		}

		String nn = String.valueOf(n);

		int count = 0;

		for (int i = 0; i < nn.length(); i++) {
			count += Integer.valueOf(nn.substring(i, i + 1));
			count = count % 9;
		}

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

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

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		BigDecimal n = sc.nextBigDecimal();
		if (n == BigDecimal.ZERO) {
			System.out.println("Yes");
			return;
		}

		String nn = String.valueOf(n);

		int count = 0;

		for (int i = 0; i < nn.length(); i++) {
			count += Integer.valueOf(nn.substring(i, i + 1));
			count = count % 9;
		}

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

	}
} Main public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		BigDecimal n = sc.nextBigDecimal();
		if (n == BigDecimal.ZERO) {
			System.out.println("Yes");
			return;
		}

		String nn = String.valueOf(n);

		int count = 0;

		for (int i = 0; i < nn.length(); i++) {
			count += Integer.valueOf(nn.substring(i, i + 1));
			count = count % 9;
		}

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

	} main {

		Scanner sc = new Scanner(System.in);

		BigDecimal n = sc.nextBigDecimal();
		if (n == BigDecimal.ZERO) {
			System.out.println("Yes");
			return;
		}

		String nn = String.valueOf(n);

		int count = 0;

		for (int i = 0; i < nn.length(); i++) {
			count += Integer.valueOf(nn.substring(i, i + 1));
			count = count % 9;
		}

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

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) BigDecimal n = sc.nextBigDecimal(); n sc.nextBigDecimal() sc.nextBigDecimal sc if (n == BigDecimal.ZERO) {
			System.out.println("Yes");
			return;
		} n == BigDecimal.ZERO n BigDecimal.ZERO BigDecimal BigDecimal.ZERO {
			System.out.println("Yes");
			return;
		} System.out.println("Yes") System.out.println System.out System System.out "Yes" return; String nn = String.valueOf(n); nn String.valueOf(n) String.valueOf String n int count = 0; count 0 for (int i = 0; i < nn.length(); i++) {
			count += Integer.valueOf(nn.substring(i, i + 1));
			count = count % 9;
		} int i = 0; int i = 0; i 0 i < nn.length() i nn.length() nn.length nn i++ i++ i {
			count += Integer.valueOf(nn.substring(i, i + 1));
			count = count % 9;
		} {
			count += Integer.valueOf(nn.substring(i, i + 1));
			count = count % 9;
		} count += Integer.valueOf(nn.substring(i, i + 1)) count Integer.valueOf(nn.substring(i, i + 1)) Integer.valueOf Integer nn.substring(i, i + 1) nn.substring nn i i + 1 i 1 count = count % 9 count count % 9 count 9 if (count % 9 == 0) {
			System.out.println("Yes");
			return;
		} count % 9 == 0 count % 9 count 9 0 {
			System.out.println("Yes");
			return;
		} System.out.println("Yes") System.out.println System.out System System.out "Yes" return; 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) {

		Scanner sc = new Scanner(System.in);

		BigDecimal n = sc.nextBigDecimal();
		if (n == BigDecimal.ZERO) {
			System.out.println("Yes");
			return;
		}

		String nn = String.valueOf(n);

		int count = 0;

		for (int i = 0; i < nn.length(); i++) {
			count += Integer.valueOf(nn.substring(i, i + 1));
			count = count % 9;
		}

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

	}
} public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		BigDecimal n = sc.nextBigDecimal();
		if (n == BigDecimal.ZERO) {
			System.out.println("Yes");
			return;
		}

		String nn = String.valueOf(n);

		int count = 0;

		for (int i = 0; i < nn.length(); i++) {
			count += Integer.valueOf(nn.substring(i, i + 1));
			count = count % 9;
		}

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

	}
} Main
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		BigDecimal n = sc.nextBigDecimal();
		if (n == BigDecimal.ZERO) {
			System.out.println("Yes");
			return;
		}

		String nn = String.valueOf(n);

		int count = 0;

		for (int i = 0; i < nn.length(); i++) {
			count += Integer.valueOf(nn.substring(i, i + 1));
			count = count % 9;
		}

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

	}
}