import java.util.*;
import java.math.BigInteger;
// warm-up
// Tribute to number 9 huh? As long as i can practice here at Atcoder. Thank you
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		BigInteger b = BigInteger.ZERO;
		BigInteger NINE = new BigInteger("9");
		for (char ch : sc.next().toCharArray()) b=b.add(new BigInteger(""+ch));
		System.out.println(b.mod(NINE).equals(BigInteger.ZERO) ? "Yes" : "No");
		sc.close();		
	}

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

} import java.util.*; util.* java import java.math.BigInteger; BigInteger java.math public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		BigInteger b = BigInteger.ZERO;
		BigInteger NINE = new BigInteger("9");
		for (char ch : sc.next().toCharArray()) b=b.add(new BigInteger(""+ch));
		System.out.println(b.mod(NINE).equals(BigInteger.ZERO) ? "Yes" : "No");
		sc.close();		
	}

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

} Main static void solve() {
		Scanner sc = new Scanner(System.in);
		BigInteger b = BigInteger.ZERO;
		BigInteger NINE = new BigInteger("9");
		for (char ch : sc.next().toCharArray()) b=b.add(new BigInteger(""+ch));
		System.out.println(b.mod(NINE).equals(BigInteger.ZERO) ? "Yes" : "No");
		sc.close();		
	} solve {
		Scanner sc = new Scanner(System.in);
		BigInteger b = BigInteger.ZERO;
		BigInteger NINE = new BigInteger("9");
		for (char ch : sc.next().toCharArray()) b=b.add(new BigInteger(""+ch));
		System.out.println(b.mod(NINE).equals(BigInteger.ZERO) ? "Yes" : "No");
		sc.close();		
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) BigInteger b = BigInteger.ZERO; b BigInteger.ZERO BigInteger BigInteger.ZERO BigInteger NINE = new BigInteger("9"); NINE new BigInteger("9") for (char ch : sc.next().toCharArray()) b=b.add(new BigInteger(""+ch)); char ch sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc b=b.add(new BigInteger(""+ch)); b=b.add(new BigInteger(""+ch)) b b.add(new BigInteger(""+ch)) b.add b new BigInteger(""+ch) System.out.println(b.mod(NINE).equals(BigInteger.ZERO) ? "Yes" : "No") System.out.println System.out System System.out b.mod(NINE).equals(BigInteger.ZERO) ? "Yes" : "No" b.mod(NINE).equals(BigInteger.ZERO) b.mod(NINE).equals b.mod(NINE) b.mod b NINE BigInteger.ZERO BigInteger BigInteger.ZERO "Yes" "No" sc.close() sc.close sc public static void main(String args[]) {
		solve();
	} main {
		solve();
	} solve() solve String args[] args public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		BigInteger b = BigInteger.ZERO;
		BigInteger NINE = new BigInteger("9");
		for (char ch : sc.next().toCharArray()) b=b.add(new BigInteger(""+ch));
		System.out.println(b.mod(NINE).equals(BigInteger.ZERO) ? "Yes" : "No");
		sc.close();		
	}

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

} public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		BigInteger b = BigInteger.ZERO;
		BigInteger NINE = new BigInteger("9");
		for (char ch : sc.next().toCharArray()) b=b.add(new BigInteger(""+ch));
		System.out.println(b.mod(NINE).equals(BigInteger.ZERO) ? "Yes" : "No");
		sc.close();		
	}

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

} Main
import java.util.*;
import java.math.BigInteger;
// warm-up
// Tribute to number 9 huh? As long as i can practice here at Atcoder. Thank you
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		BigInteger b = BigInteger.ZERO;
		BigInteger NINE = new BigInteger("9");
		for (char ch : sc.next().toCharArray()) b=b.add(new BigInteger(""+ch));
		System.out.println(b.mod(NINE).equals(BigInteger.ZERO) ? "Yes" : "No");
		sc.close();		
	}

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

}
