import java.util.*;

public class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	String nis = sc.next();
	int now;
	int sum = 0;
	for (int i=0; i<nis.length(); i++) {
	    now = Character.getNumericValue(nis.charAt(i));
	    sum += now;
	}
	if (sum % 9 == 0) System.out.print("Yes");
	else { System.out.print("No"); }
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	String nis = sc.next();
	int now;
	int sum = 0;
	for (int i=0; i<nis.length(); i++) {
	    now = Character.getNumericValue(nis.charAt(i));
	    sum += now;
	}
	if (sum % 9 == 0) System.out.print("Yes");
	else { System.out.print("No"); }
    }
} Main public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	String nis = sc.next();
	int now;
	int sum = 0;
	for (int i=0; i<nis.length(); i++) {
	    now = Character.getNumericValue(nis.charAt(i));
	    sum += now;
	}
	if (sum % 9 == 0) System.out.print("Yes");
	else { System.out.print("No"); }
    } main {
	Scanner sc = new Scanner(System.in);
	String nis = sc.next();
	int now;
	int sum = 0;
	for (int i=0; i<nis.length(); i++) {
	    now = Character.getNumericValue(nis.charAt(i));
	    sum += now;
	}
	if (sum % 9 == 0) System.out.print("Yes");
	else { System.out.print("No"); }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String nis = sc.next(); nis sc.next() sc.next sc int now; now int sum = 0; sum 0 for (int i=0; i<nis.length(); i++) {
	    now = Character.getNumericValue(nis.charAt(i));
	    sum += now;
	} int i=0; int i=0; i 0 i<nis.length() i nis.length() nis.length nis i++ i++ i {
	    now = Character.getNumericValue(nis.charAt(i));
	    sum += now;
	} {
	    now = Character.getNumericValue(nis.charAt(i));
	    sum += now;
	} now = Character.getNumericValue(nis.charAt(i)) now Character.getNumericValue(nis.charAt(i)) Character.getNumericValue Character nis.charAt(i) nis.charAt nis i sum += now sum now if (sum % 9 == 0) System.out.print("Yes");
	else { System.out.print("No"); } sum % 9 == 0 sum % 9 sum 9 0 System.out.print("Yes") System.out.print System.out System System.out "Yes" { System.out.print("No"); } System.out.print("No") System.out.print System.out System System.out "No" String[] args args public class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	String nis = sc.next();
	int now;
	int sum = 0;
	for (int i=0; i<nis.length(); i++) {
	    now = Character.getNumericValue(nis.charAt(i));
	    sum += now;
	}
	if (sum % 9 == 0) System.out.print("Yes");
	else { System.out.print("No"); }
    }
} public class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	String nis = sc.next();
	int now;
	int sum = 0;
	for (int i=0; i<nis.length(); i++) {
	    now = Character.getNumericValue(nis.charAt(i));
	    sum += now;
	}
	if (sum % 9 == 0) System.out.print("Yes");
	else { System.out.print("No"); }
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	String nis = sc.next();
	int now;
	int sum = 0;
	for (int i=0; i<nis.length(); i++) {
	    now = Character.getNumericValue(nis.charAt(i));
	    sum += now;
	}
	if (sum % 9 == 0) System.out.print("Yes");
	else { System.out.print("No"); }
    }
}
