import java.util.Scanner;

public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int r = 0;
		for (char c : s.toCharArray()) {
			r += c - '0';
		}
		System.out.println(r%9==0?"Yes":"No");
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int r = 0;
		for (char c : s.toCharArray()) {
			r += c - '0';
		}
		System.out.println(r%9==0?"Yes":"No");
	}
} Main public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int r = 0;
		for (char c : s.toCharArray()) {
			r += c - '0';
		}
		System.out.println(r%9==0?"Yes":"No");
	} main {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int r = 0;
		for (char c : s.toCharArray()) {
			r += c - '0';
		}
		System.out.println(r%9==0?"Yes":"No");
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc int r = 0; r 0 for (char c : s.toCharArray()) {
			r += c - '0';
		} char c s.toCharArray() s.toCharArray s {
			r += c - '0';
		} {
			r += c - '0';
		} r += c - '0' r c - '0' c '0' System.out.println(r%9==0?"Yes":"No") System.out.println System.out System System.out r%9==0?"Yes":"No" r%9==0 r%9 r 9 0 "Yes" "No" final String[] args args public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int r = 0;
		for (char c : s.toCharArray()) {
			r += c - '0';
		}
		System.out.println(r%9==0?"Yes":"No");
	}
} public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int r = 0;
		for (char c : s.toCharArray()) {
			r += c - '0';
		}
		System.out.println(r%9==0?"Yes":"No");
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int r = 0;
		for (char c : s.toCharArray()) {
			r += c - '0';
		}
		System.out.println(r%9==0?"Yes":"No");
	}
}
