import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scn  = new Scanner(System.in);
		String num = scn.next();
		int res = 0;
		for(char c:num.toCharArray())
		{
			int temp = (int)c-'0';
			res+=temp;
		}
		if(res%9==0)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		Scanner scn  = new Scanner(System.in);
		String num = scn.next();
		int res = 0;
		for(char c:num.toCharArray())
		{
			int temp = (int)c-'0';
			res+=temp;
		}
		if(res%9==0)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
} Main public static void main(String[] args) {
		Scanner scn  = new Scanner(System.in);
		String num = scn.next();
		int res = 0;
		for(char c:num.toCharArray())
		{
			int temp = (int)c-'0';
			res+=temp;
		}
		if(res%9==0)
			System.out.println("Yes");
		else
			System.out.println("No");
	} main {
		Scanner scn  = new Scanner(System.in);
		String num = scn.next();
		int res = 0;
		for(char c:num.toCharArray())
		{
			int temp = (int)c-'0';
			res+=temp;
		}
		if(res%9==0)
			System.out.println("Yes");
		else
			System.out.println("No");
	} Scanner scn  = new Scanner(System.in); scn new Scanner(System.in) String num = scn.next(); num scn.next() scn.next scn int res = 0; res 0 for(char c:num.toCharArray())
		{
			int temp = (int)c-'0';
			res+=temp;
		} char c num.toCharArray() num.toCharArray num {
			int temp = (int)c-'0';
			res+=temp;
		} {
			int temp = (int)c-'0';
			res+=temp;
		} int temp = (int)c-'0'; temp (int)c-'0' (int)c '0' res+=temp res temp if(res%9==0)
			System.out.println("Yes");
		else
			System.out.println("No"); res%9==0 res%9 res 9 0 System.out.println("Yes") System.out.println System.out System System.out "Yes" 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) {
		Scanner scn  = new Scanner(System.in);
		String num = scn.next();
		int res = 0;
		for(char c:num.toCharArray())
		{
			int temp = (int)c-'0';
			res+=temp;
		}
		if(res%9==0)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scn  = new Scanner(System.in);
		String num = scn.next();
		int res = 0;
		for(char c:num.toCharArray())
		{
			int temp = (int)c-'0';
			res+=temp;
		}
		if(res%9==0)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
} Main
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scn  = new Scanner(System.in);
		String num = scn.next();
		int res = 0;
		for(char c:num.toCharArray())
		{
			int temp = (int)c-'0';
			res+=temp;
		}
		if(res%9==0)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}
