import java.util.*;
import java.io.*;
public class Main
{
	static final int mod=(int)1e9+7;
	static final int inf=(int)1e9;
	static final long INF=(long)1e18;
	public static void main(String[] args)
	{
		FastScanner fs=new FastScanner();
		String s=fs.next();
		int sum=0;
		for(int i=0;i<s.length();i++)
		{
			sum=sum+Character.getNumericValue(s.charAt(i));
		}
		System.out.println(sum%9==0 ? "Yes":"No");	
	}
}
class FastScanner 
{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		public String next() 
		{
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
			
		}
		ArrayList<Integer> sieve(int n)
		{
			ArrayList<Integer> primes = new ArrayList<Integer>();
			boolean arr[]=new boolean[n+1];
			Arrays.fill(arr,true);
			arr[0]=arr[1]=false;
			for(int i=2;i*i<=n;i++)
			{
				if(arr[i]==true)
				{
					for(int j=i*i;j<arr.length;j+=i)
					{
						arr[j]=false;
					}
				}
			}
			for(int i=0;i<arr.length;i++)
			{
				if(arr[i]==true)primes.add(i);
			}
			return primes;
		}
		long pow(long x,long n)
		{
			long res=1;
			while(n>0)
			{
			   	if(n%2!=0)
			   	{
			   		res=(res*x);n--;
			   	}
			   	else
			   	{
			   		x=(x*x);n/=2;
			   	}
			}
			return res;
		}
		int gcd(int a,int b)
		{
			if(b==0)
			{
				return a;
			}
			return gcd(b,a%b);
		}
		long longgcd(long a,long b)
		{
			if(b==0)
			{
				return a;
			}
			return longgcd(b,a%b);
		}
		int[] sort(int arr[])
		{
			ArrayList<Integer> list = new ArrayList<Integer>();
			for(int i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		char[] charsort(char arr[])
	        {
	    	ArrayList<Character> list = new ArrayList<>();
	    	for(char c:arr)list.add(c);
	    	Collections.sort(list);
	    	for(int i=0;i<list.size();i++)
	    	{
	    		arr[i]=list.get(i);
	    	}
	    	return arr;
	        }
		long[] longsort(long arr[])
		{
			ArrayList<Long> list = new ArrayList<Long>();
			for(long i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		public int nextInt() 
		{
			return Integer.parseInt(next());
		}
		public int[] readArray(int n)
		{
			int[] arr=new int[n];
			for (int i=0; i<n; i++) arr[i]=nextInt();
			return arr;
		}	
		public long nextLong()
		{
			return Long.parseLong(next());
		}
		public long[] longreadArray(int n) 
		{
			long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
} import java.util.*; util.* java import java.io.*; io.* java public class Main
{
	static final int mod=(int)1e9+7;
	static final int inf=(int)1e9;
	static final long INF=(long)1e18;
	public static void main(String[] args)
	{
		FastScanner fs=new FastScanner();
		String s=fs.next();
		int sum=0;
		for(int i=0;i<s.length();i++)
		{
			sum=sum+Character.getNumericValue(s.charAt(i));
		}
		System.out.println(sum%9==0 ? "Yes":"No");	
	}
} Main static final int mod=(int)1e9+7; mod (int)1e9+7 (int)1e9 7 static final int inf=(int)1e9; inf (int)1e9 static final long INF=(long)1e18; INF (long)1e18 public static void main(String[] args)
	{
		FastScanner fs=new FastScanner();
		String s=fs.next();
		int sum=0;
		for(int i=0;i<s.length();i++)
		{
			sum=sum+Character.getNumericValue(s.charAt(i));
		}
		System.out.println(sum%9==0 ? "Yes":"No");	
	} main {
		FastScanner fs=new FastScanner();
		String s=fs.next();
		int sum=0;
		for(int i=0;i<s.length();i++)
		{
			sum=sum+Character.getNumericValue(s.charAt(i));
		}
		System.out.println(sum%9==0 ? "Yes":"No");	
	} FastScanner fs=new FastScanner(); fs new FastScanner() String s=fs.next(); s fs.next() fs.next fs int sum=0; sum 0 for(int i=0;i<s.length();i++)
		{
			sum=sum+Character.getNumericValue(s.charAt(i));
		} int i=0; int i=0; i 0 i<s.length() i s.length() s.length s i++ i++ i {
			sum=sum+Character.getNumericValue(s.charAt(i));
		} {
			sum=sum+Character.getNumericValue(s.charAt(i));
		} sum=sum+Character.getNumericValue(s.charAt(i)) sum sum+Character.getNumericValue(s.charAt(i)) sum Character.getNumericValue(s.charAt(i)) Character.getNumericValue Character s.charAt(i) s.charAt s i System.out.println(sum%9==0 ? "Yes":"No") System.out.println System.out System System.out sum%9==0 ? "Yes":"No" sum%9==0 sum%9 sum 9 0 "Yes" "No" String[] args args class FastScanner 
{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		public String next() 
		{
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
			
		}
		ArrayList<Integer> sieve(int n)
		{
			ArrayList<Integer> primes = new ArrayList<Integer>();
			boolean arr[]=new boolean[n+1];
			Arrays.fill(arr,true);
			arr[0]=arr[1]=false;
			for(int i=2;i*i<=n;i++)
			{
				if(arr[i]==true)
				{
					for(int j=i*i;j<arr.length;j+=i)
					{
						arr[j]=false;
					}
				}
			}
			for(int i=0;i<arr.length;i++)
			{
				if(arr[i]==true)primes.add(i);
			}
			return primes;
		}
		long pow(long x,long n)
		{
			long res=1;
			while(n>0)
			{
			   	if(n%2!=0)
			   	{
			   		res=(res*x);n--;
			   	}
			   	else
			   	{
			   		x=(x*x);n/=2;
			   	}
			}
			return res;
		}
		int gcd(int a,int b)
		{
			if(b==0)
			{
				return a;
			}
			return gcd(b,a%b);
		}
		long longgcd(long a,long b)
		{
			if(b==0)
			{
				return a;
			}
			return longgcd(b,a%b);
		}
		int[] sort(int arr[])
		{
			ArrayList<Integer> list = new ArrayList<Integer>();
			for(int i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		char[] charsort(char arr[])
	        {
	    	ArrayList<Character> list = new ArrayList<>();
	    	for(char c:arr)list.add(c);
	    	Collections.sort(list);
	    	for(int i=0;i<list.size();i++)
	    	{
	    		arr[i]=list.get(i);
	    	}
	    	return arr;
	        }
		long[] longsort(long arr[])
		{
			ArrayList<Long> list = new ArrayList<Long>();
			for(long i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		public int nextInt() 
		{
			return Integer.parseInt(next());
		}
		public int[] readArray(int n)
		{
			int[] arr=new int[n];
			for (int i=0; i<n; i++) arr[i]=nextInt();
			return arr;
		}	
		public long nextLong()
		{
			return Long.parseLong(next());
		}
		public long[] longreadArray(int n) 
		{
			long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
} FastScanner BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringTokenizer st = new StringTokenizer(""); st new StringTokenizer("") public String next() 
		{
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
			
		} next {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
			
		} while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				} !st.hasMoreTokens() st.hasMoreTokens() st.hasMoreTokens st try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				} catch (IOException e) {
					e.printStackTrace();
				} IOException e {
					e.printStackTrace();
				} e.printStackTrace() e.printStackTrace e {
					st=new StringTokenizer(br.readLine());
				} st=new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) return st.nextToken(); st.nextToken() st.nextToken st ArrayList<Integer> sieve(int n)
		{
			ArrayList<Integer> primes = new ArrayList<Integer>();
			boolean arr[]=new boolean[n+1];
			Arrays.fill(arr,true);
			arr[0]=arr[1]=false;
			for(int i=2;i*i<=n;i++)
			{
				if(arr[i]==true)
				{
					for(int j=i*i;j<arr.length;j+=i)
					{
						arr[j]=false;
					}
				}
			}
			for(int i=0;i<arr.length;i++)
			{
				if(arr[i]==true)primes.add(i);
			}
			return primes;
		} sieve {
			ArrayList<Integer> primes = new ArrayList<Integer>();
			boolean arr[]=new boolean[n+1];
			Arrays.fill(arr,true);
			arr[0]=arr[1]=false;
			for(int i=2;i*i<=n;i++)
			{
				if(arr[i]==true)
				{
					for(int j=i*i;j<arr.length;j+=i)
					{
						arr[j]=false;
					}
				}
			}
			for(int i=0;i<arr.length;i++)
			{
				if(arr[i]==true)primes.add(i);
			}
			return primes;
		} ArrayList<Integer> primes = new ArrayList<Integer>(); primes new ArrayList<Integer>() boolean arr[]=new boolean[n+1]; arr new boolean[n+1] n+1 n 1 Arrays.fill(arr,true) Arrays.fill Arrays arr true arr[0]=arr[1]=false arr[0] arr 0 arr[1]=false arr[1] arr 1 false for(int i=2;i*i<=n;i++)
			{
				if(arr[i]==true)
				{
					for(int j=i*i;j<arr.length;j+=i)
					{
						arr[j]=false;
					}
				}
			} int i=2; int i=2; i 2 i*i<=n i*i i i n i++ i++ i {
				if(arr[i]==true)
				{
					for(int j=i*i;j<arr.length;j+=i)
					{
						arr[j]=false;
					}
				}
			} {
				if(arr[i]==true)
				{
					for(int j=i*i;j<arr.length;j+=i)
					{
						arr[j]=false;
					}
				}
			} if(arr[i]==true)
				{
					for(int j=i*i;j<arr.length;j+=i)
					{
						arr[j]=false;
					}
				} arr[i]==true arr[i] arr i true {
					for(int j=i*i;j<arr.length;j+=i)
					{
						arr[j]=false;
					}
				} for(int j=i*i;j<arr.length;j+=i)
					{
						arr[j]=false;
					} int j=i*i; int j=i*i; j i*i i i j<arr.length j arr.length arr arr.length j+=i j+=i j i {
						arr[j]=false;
					} {
						arr[j]=false;
					} arr[j]=false arr[j] arr j false for(int i=0;i<arr.length;i++)
			{
				if(arr[i]==true)primes.add(i);
			} int i=0; int i=0; i 0 i<arr.length i arr.length arr arr.length i++ i++ i {
				if(arr[i]==true)primes.add(i);
			} {
				if(arr[i]==true)primes.add(i);
			} if(arr[i]==true)primes.add(i); arr[i]==true arr[i] arr i true primes.add(i) primes.add primes i return primes; primes int n n long pow(long x,long n)
		{
			long res=1;
			while(n>0)
			{
			   	if(n%2!=0)
			   	{
			   		res=(res*x);n--;
			   	}
			   	else
			   	{
			   		x=(x*x);n/=2;
			   	}
			}
			return res;
		} pow {
			long res=1;
			while(n>0)
			{
			   	if(n%2!=0)
			   	{
			   		res=(res*x);n--;
			   	}
			   	else
			   	{
			   		x=(x*x);n/=2;
			   	}
			}
			return res;
		} long res=1; res 1 while(n>0)
			{
			   	if(n%2!=0)
			   	{
			   		res=(res*x);n--;
			   	}
			   	else
			   	{
			   		x=(x*x);n/=2;
			   	}
			} n>0 n 0 {
			   	if(n%2!=0)
			   	{
			   		res=(res*x);n--;
			   	}
			   	else
			   	{
			   		x=(x*x);n/=2;
			   	}
			} if(n%2!=0)
			   	{
			   		res=(res*x);n--;
			   	}
			   	else
			   	{
			   		x=(x*x);n/=2;
			   	} n%2!=0 n%2 n 2 0 {
			   		res=(res*x);n--;
			   	} res=(res*x) res (res*x) res x n-- n {
			   		x=(x*x);n/=2;
			   	} x=(x*x) x (x*x) x x n/=2 n 2 return res; res long x x long n n int gcd(int a,int b)
		{
			if(b==0)
			{
				return a;
			}
			return gcd(b,a%b);
		} gcd {
			if(b==0)
			{
				return a;
			}
			return gcd(b,a%b);
		} if(b==0)
			{
				return a;
			} b==0 b 0 {
				return a;
			} return a; a return gcd(b,a%b); gcd(b,a%b) gcd b a%b a b int a a int b b long longgcd(long a,long b)
		{
			if(b==0)
			{
				return a;
			}
			return longgcd(b,a%b);
		} longgcd {
			if(b==0)
			{
				return a;
			}
			return longgcd(b,a%b);
		} if(b==0)
			{
				return a;
			} b==0 b 0 {
				return a;
			} return a; a return longgcd(b,a%b); longgcd(b,a%b) longgcd b a%b a b long a a long b b int[] sort(int arr[])
		{
			ArrayList<Integer> list = new ArrayList<Integer>();
			for(int i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		} sort {
			ArrayList<Integer> list = new ArrayList<Integer>();
			for(int i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		} ArrayList<Integer> list = new ArrayList<Integer>(); list new ArrayList<Integer>() for(int i:arr)list.add(i); int i arr list.add(i); list.add(i) list.add list i Collections.sort(list) Collections.sort Collections list for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			} int i=0; int i=0; i 0 i<arr.length i arr.length arr arr.length i++ i++ i {
				arr[i]=list.get(i);
			} {
				arr[i]=list.get(i);
			} arr[i]=list.get(i) arr[i] arr i list.get(i) list.get list i return arr; arr int arr[] arr char[] charsort(char arr[])
	        {
	    	ArrayList<Character> list = new ArrayList<>();
	    	for(char c:arr)list.add(c);
	    	Collections.sort(list);
	    	for(int i=0;i<list.size();i++)
	    	{
	    		arr[i]=list.get(i);
	    	}
	    	return arr;
	        } charsort {
	    	ArrayList<Character> list = new ArrayList<>();
	    	for(char c:arr)list.add(c);
	    	Collections.sort(list);
	    	for(int i=0;i<list.size();i++)
	    	{
	    		arr[i]=list.get(i);
	    	}
	    	return arr;
	        } ArrayList<Character> list = new ArrayList<>(); list new ArrayList<>() for(char c:arr)list.add(c); char c arr list.add(c); list.add(c) list.add list c Collections.sort(list) Collections.sort Collections list for(int i=0;i<list.size();i++)
	    	{
	    		arr[i]=list.get(i);
	    	} int i=0; int i=0; i 0 i<list.size() i list.size() list.size list i++ i++ i {
	    		arr[i]=list.get(i);
	    	} {
	    		arr[i]=list.get(i);
	    	} arr[i]=list.get(i) arr[i] arr i list.get(i) list.get list i return arr; arr char arr[] arr long[] longsort(long arr[])
		{
			ArrayList<Long> list = new ArrayList<Long>();
			for(long i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		} longsort {
			ArrayList<Long> list = new ArrayList<Long>();
			for(long i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		} ArrayList<Long> list = new ArrayList<Long>(); list new ArrayList<Long>() for(long i:arr)list.add(i); long i arr list.add(i); list.add(i) list.add list i Collections.sort(list) Collections.sort Collections list for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			} int i=0; int i=0; i 0 i<arr.length i arr.length arr arr.length i++ i++ i {
				arr[i]=list.get(i);
			} {
				arr[i]=list.get(i);
			} arr[i]=list.get(i) arr[i] arr i list.get(i) list.get list i return arr; arr long arr[] arr public int nextInt() 
		{
			return Integer.parseInt(next());
		} nextInt {
			return Integer.parseInt(next());
		} return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next public int[] readArray(int n)
		{
			int[] arr=new int[n];
			for (int i=0; i<n; i++) arr[i]=nextInt();
			return arr;
		} readArray {
			int[] arr=new int[n];
			for (int i=0; i<n; i++) arr[i]=nextInt();
			return arr;
		} int[] arr=new int[n]; arr new int[n] n for (int i=0; i<n; i++) arr[i]=nextInt(); int i=0; int i=0; i 0 i<n i n i++ i++ i arr[i]=nextInt(); arr[i]=nextInt() arr[i] arr i nextInt() nextInt return arr; arr int n n public long nextLong()
		{
			return Long.parseLong(next());
		} nextLong {
			return Long.parseLong(next());
		} return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next public long[] longreadArray(int n) 
		{
			long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		} longreadArray {
			long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		} long[] a=new long[n]; a new long[n] n for (int i=0; i<n; i++) a[i]=nextLong(); int i=0; int i=0; i 0 i<n i n i++ i++ i a[i]=nextLong(); a[i]=nextLong() a[i] a i nextLong() nextLong return a; a int n n public class Main
{
	static final int mod=(int)1e9+7;
	static final int inf=(int)1e9;
	static final long INF=(long)1e18;
	public static void main(String[] args)
	{
		FastScanner fs=new FastScanner();
		String s=fs.next();
		int sum=0;
		for(int i=0;i<s.length();i++)
		{
			sum=sum+Character.getNumericValue(s.charAt(i));
		}
		System.out.println(sum%9==0 ? "Yes":"No");	
	}
} public class Main
{
	static final int mod=(int)1e9+7;
	static final int inf=(int)1e9;
	static final long INF=(long)1e18;
	public static void main(String[] args)
	{
		FastScanner fs=new FastScanner();
		String s=fs.next();
		int sum=0;
		for(int i=0;i<s.length();i++)
		{
			sum=sum+Character.getNumericValue(s.charAt(i));
		}
		System.out.println(sum%9==0 ? "Yes":"No");	
	}
} Main
import java.util.*;
import java.io.*;
public class Main
{
	static final int mod=(int)1e9+7;
	static final int inf=(int)1e9;
	static final long INF=(long)1e18;
	public static void main(String[] args)
	{
		FastScanner fs=new FastScanner();
		String s=fs.next();
		int sum=0;
		for(int i=0;i<s.length();i++)
		{
			sum=sum+Character.getNumericValue(s.charAt(i));
		}
		System.out.println(sum%9==0 ? "Yes":"No");	
	}
}
class FastScanner 
{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		public String next() 
		{
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
			
		}
		ArrayList<Integer> sieve(int n)
		{
			ArrayList<Integer> primes = new ArrayList<Integer>();
			boolean arr[]=new boolean[n+1];
			Arrays.fill(arr,true);
			arr[0]=arr[1]=false;
			for(int i=2;i*i<=n;i++)
			{
				if(arr[i]==true)
				{
					for(int j=i*i;j<arr.length;j+=i)
					{
						arr[j]=false;
					}
				}
			}
			for(int i=0;i<arr.length;i++)
			{
				if(arr[i]==true)primes.add(i);
			}
			return primes;
		}
		long pow(long x,long n)
		{
			long res=1;
			while(n>0)
			{
			   	if(n%2!=0)
			   	{
			   		res=(res*x);n--;
			   	}
			   	else
			   	{
			   		x=(x*x);n/=2;
			   	}
			}
			return res;
		}
		int gcd(int a,int b)
		{
			if(b==0)
			{
				return a;
			}
			return gcd(b,a%b);
		}
		long longgcd(long a,long b)
		{
			if(b==0)
			{
				return a;
			}
			return longgcd(b,a%b);
		}
		int[] sort(int arr[])
		{
			ArrayList<Integer> list = new ArrayList<Integer>();
			for(int i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		char[] charsort(char arr[])
	        {
	    	ArrayList<Character> list = new ArrayList<>();
	    	for(char c:arr)list.add(c);
	    	Collections.sort(list);
	    	for(int i=0;i<list.size();i++)
	    	{
	    		arr[i]=list.get(i);
	    	}
	    	return arr;
	        }
		long[] longsort(long arr[])
		{
			ArrayList<Long> list = new ArrayList<Long>();
			for(long i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		public int nextInt() 
		{
			return Integer.parseInt(next());
		}
		public int[] readArray(int n)
		{
			int[] arr=new int[n];
			for (int i=0; i<n; i++) arr[i]=nextInt();
			return arr;
		}	
		public long nextLong()
		{
			return Long.parseLong(next());
		}
		public long[] longreadArray(int n) 
		{
			long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
}