import java.util.Scanner;

public class Main {
	private static Scanner sc;

	public static void main(String[] args) {
		sc = new Scanner(System.in);
		String n = sc.next();
		String[] nArray = n.split("");
		long sum = 0;
		for (String nChar : nArray) {
			sum += Integer.parseInt(nChar);
		}
		
		if (0 == (sum%9)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
  		
		
	}



} import java.util.Scanner; Scanner java.util public class Main {
	private static Scanner sc;

	public static void main(String[] args) {
		sc = new Scanner(System.in);
		String n = sc.next();
		String[] nArray = n.split("");
		long sum = 0;
		for (String nChar : nArray) {
			sum += Integer.parseInt(nChar);
		}
		
		if (0 == (sum%9)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
  		
		
	}



} Main private static Scanner sc; sc public static void main(String[] args) {
		sc = new Scanner(System.in);
		String n = sc.next();
		String[] nArray = n.split("");
		long sum = 0;
		for (String nChar : nArray) {
			sum += Integer.parseInt(nChar);
		}
		
		if (0 == (sum%9)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
  		
		
	} main {
		sc = new Scanner(System.in);
		String n = sc.next();
		String[] nArray = n.split("");
		long sum = 0;
		for (String nChar : nArray) {
			sum += Integer.parseInt(nChar);
		}
		
		if (0 == (sum%9)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
  		
		
	} sc = new Scanner(System.in) sc new Scanner(System.in) String n = sc.next(); n sc.next() sc.next sc String[] nArray = n.split(""); nArray n.split("") n.split n "" long sum = 0; sum 0 for (String nChar : nArray) {
			sum += Integer.parseInt(nChar);
		} String nChar nArray {
			sum += Integer.parseInt(nChar);
		} {
			sum += Integer.parseInt(nChar);
		} sum += Integer.parseInt(nChar) sum Integer.parseInt(nChar) Integer.parseInt Integer nChar if (0 == (sum%9)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		} 0 == (sum%9) 0 (sum%9) sum 9 {
			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" String[] args args public class Main {
	private static Scanner sc;

	public static void main(String[] args) {
		sc = new Scanner(System.in);
		String n = sc.next();
		String[] nArray = n.split("");
		long sum = 0;
		for (String nChar : nArray) {
			sum += Integer.parseInt(nChar);
		}
		
		if (0 == (sum%9)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
  		
		
	}



} public class Main {
	private static Scanner sc;

	public static void main(String[] args) {
		sc = new Scanner(System.in);
		String n = sc.next();
		String[] nArray = n.split("");
		long sum = 0;
		for (String nChar : nArray) {
			sum += Integer.parseInt(nChar);
		}
		
		if (0 == (sum%9)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
  		
		
	}



} Main
import java.util.Scanner;

public class Main {
	private static Scanner sc;

	public static void main(String[] args) {
		sc = new Scanner(System.in);
		String n = sc.next();
		String[] nArray = n.split("");
		long sum = 0;
		for (String nChar : nArray) {
			sum += Integer.parseInt(nChar);
		}
		
		if (0 == (sum%9)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
  		
		
	}



}
