import java.util.*;
import java.io.*;
public class Main
{
	public static void main(String args[]) throws IOException
	{
		
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String n="";
		n=br.readLine();
		long ans=0;
		for(int i=0;i<n.length();i++)
		{
			ans+=Long.parseLong(""+n.charAt(i));
		}
		if(ans%9==0)
		{
			System.out.println("Yes");
		}
		else
		{
			System.out.println("No");
		}
	}
}		 import java.util.*; util.* java import java.io.*; io.* java public class Main
{
	public static void main(String args[]) throws IOException
	{
		
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String n="";
		n=br.readLine();
		long ans=0;
		for(int i=0;i<n.length();i++)
		{
			ans+=Long.parseLong(""+n.charAt(i));
		}
		if(ans%9==0)
		{
			System.out.println("Yes");
		}
		else
		{
			System.out.println("No");
		}
	}
} Main public static void main(String args[]) throws IOException
	{
		
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String n="";
		n=br.readLine();
		long ans=0;
		for(int i=0;i<n.length();i++)
		{
			ans+=Long.parseLong(""+n.charAt(i));
		}
		if(ans%9==0)
		{
			System.out.println("Yes");
		}
		else
		{
			System.out.println("No");
		}
	} main {
		
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String n="";
		n=br.readLine();
		long ans=0;
		for(int i=0;i<n.length();i++)
		{
			ans+=Long.parseLong(""+n.charAt(i));
		}
		if(ans%9==0)
		{
			System.out.println("Yes");
		}
		else
		{
			System.out.println("No");
		}
	} BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String n=""; n "" n=br.readLine() n br.readLine() br.readLine br long ans=0; ans 0 for(int i=0;i<n.length();i++)
		{
			ans+=Long.parseLong(""+n.charAt(i));
		} int i=0; int i=0; i 0 i<n.length() i n.length() n.length n i++ i++ i {
			ans+=Long.parseLong(""+n.charAt(i));
		} {
			ans+=Long.parseLong(""+n.charAt(i));
		} ans+=Long.parseLong(""+n.charAt(i)) ans Long.parseLong(""+n.charAt(i)) Long.parseLong Long ""+n.charAt(i) "" n.charAt(i) n.charAt n i if(ans%9==0)
		{
			System.out.println("Yes");
		}
		else
		{
			System.out.println("No");
		} ans%9==0 ans%9 ans 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[]) throws IOException
	{
		
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String n="";
		n=br.readLine();
		long ans=0;
		for(int i=0;i<n.length();i++)
		{
			ans+=Long.parseLong(""+n.charAt(i));
		}
		if(ans%9==0)
		{
			System.out.println("Yes");
		}
		else
		{
			System.out.println("No");
		}
	}
} public class Main
{
	public static void main(String args[]) throws IOException
	{
		
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String n="";
		n=br.readLine();
		long ans=0;
		for(int i=0;i<n.length();i++)
		{
			ans+=Long.parseLong(""+n.charAt(i));
		}
		if(ans%9==0)
		{
			System.out.println("Yes");
		}
		else
		{
			System.out.println("No");
		}
	}
} Main
import java.util.*;
import java.io.*;
public class Main
{
	public static void main(String args[]) throws IOException
	{
		
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String n="";
		n=br.readLine();
		long ans=0;
		for(int i=0;i<n.length();i++)
		{
			ans+=Long.parseLong(""+n.charAt(i));
		}
		if(ans%9==0)
		{
			System.out.println("Yes");
		}
		else
		{
			System.out.println("No");
		}
	}
}		