import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner (System.in);
		
		String n = sc.next();
		String chkNumStr = "";
		int chkNum=0;
		
		
		
		while(n.length() != 0) {
			chkNumStr = n.substring(0, 1);
			chkNum = chkNum + Integer.parseInt(chkNumStr);
			n = n.substring(1, n.length());
		}
		if(chkNum%9 == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner (System.in);
		
		String n = sc.next();
		String chkNumStr = "";
		int chkNum=0;
		
		
		
		while(n.length() != 0) {
			chkNumStr = n.substring(0, 1);
			chkNum = chkNum + Integer.parseInt(chkNumStr);
			n = n.substring(1, n.length());
		}
		if(chkNum%9 == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner (System.in);
		
		String n = sc.next();
		String chkNumStr = "";
		int chkNum=0;
		
		
		
		while(n.length() != 0) {
			chkNumStr = n.substring(0, 1);
			chkNum = chkNum + Integer.parseInt(chkNumStr);
			n = n.substring(1, n.length());
		}
		if(chkNum%9 == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	} main {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner (System.in);
		
		String n = sc.next();
		String chkNumStr = "";
		int chkNum=0;
		
		
		
		while(n.length() != 0) {
			chkNumStr = n.substring(0, 1);
			chkNum = chkNum + Integer.parseInt(chkNumStr);
			n = n.substring(1, n.length());
		}
		if(chkNum%9 == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	} Scanner sc = new Scanner (System.in); sc new Scanner (System.in) String n = sc.next(); n sc.next() sc.next sc String chkNumStr = ""; chkNumStr "" int chkNum=0; chkNum 0 while(n.length() != 0) {
			chkNumStr = n.substring(0, 1);
			chkNum = chkNum + Integer.parseInt(chkNumStr);
			n = n.substring(1, n.length());
		} n.length() != 0 n.length() n.length n 0 {
			chkNumStr = n.substring(0, 1);
			chkNum = chkNum + Integer.parseInt(chkNumStr);
			n = n.substring(1, n.length());
		} chkNumStr = n.substring(0, 1) chkNumStr n.substring(0, 1) n.substring n 0 1 chkNum = chkNum + Integer.parseInt(chkNumStr) chkNum chkNum + Integer.parseInt(chkNumStr) chkNum Integer.parseInt(chkNumStr) Integer.parseInt Integer chkNumStr n = n.substring(1, n.length()) n n.substring(1, n.length()) n.substring n 1 n.length() n.length n if(chkNum%9 == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		} chkNum%9 == 0 chkNum%9 chkNum 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" String[] args args public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner (System.in);
		
		String n = sc.next();
		String chkNumStr = "";
		int chkNum=0;
		
		
		
		while(n.length() != 0) {
			chkNumStr = n.substring(0, 1);
			chkNum = chkNum + Integer.parseInt(chkNumStr);
			n = n.substring(1, n.length());
		}
		if(chkNum%9 == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

} public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner (System.in);
		
		String n = sc.next();
		String chkNumStr = "";
		int chkNum=0;
		
		
		
		while(n.length() != 0) {
			chkNumStr = n.substring(0, 1);
			chkNum = chkNum + Integer.parseInt(chkNumStr);
			n = n.substring(1, n.length());
		}
		if(chkNum%9 == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner (System.in);
		
		String n = sc.next();
		String chkNumStr = "";
		int chkNum=0;
		
		
		
		while(n.length() != 0) {
			chkNumStr = n.substring(0, 1);
			chkNum = chkNum + Integer.parseInt(chkNumStr);
			n = n.substring(1, n.length());
		}
		if(chkNum%9 == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}