 
 import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
 public class Main
 {
 	public static void main(String[]args)
 	{
 		Scanner sc=new Scanner (System.in);
 		//int t=sc.nextInt();
 		String str=sc.next();
 		int n=str.length();
 		int i,temp=0;
 		for(i=0;i<n;i++)
 		{
 			
 			String s=str.substring(i,i+1);
 			int x=Integer.parseInt(s);
 			temp=temp+x;
 		}
 		if(temp%9==0)System.out.println("Yes");
 		else System.out.println("No");
 	}
 } import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.*; util.* java public class Main
 {
 	public static void main(String[]args)
 	{
 		Scanner sc=new Scanner (System.in);
 		//int t=sc.nextInt();
 		String str=sc.next();
 		int n=str.length();
 		int i,temp=0;
 		for(i=0;i<n;i++)
 		{
 			
 			String s=str.substring(i,i+1);
 			int x=Integer.parseInt(s);
 			temp=temp+x;
 		}
 		if(temp%9==0)System.out.println("Yes");
 		else System.out.println("No");
 	}
 } Main public static void main(String[]args)
 	{
 		Scanner sc=new Scanner (System.in);
 		//int t=sc.nextInt();
 		String str=sc.next();
 		int n=str.length();
 		int i,temp=0;
 		for(i=0;i<n;i++)
 		{
 			
 			String s=str.substring(i,i+1);
 			int x=Integer.parseInt(s);
 			temp=temp+x;
 		}
 		if(temp%9==0)System.out.println("Yes");
 		else System.out.println("No");
 	} main {
 		Scanner sc=new Scanner (System.in);
 		//int t=sc.nextInt();
 		String str=sc.next();
 		int n=str.length();
 		int i,temp=0;
 		for(i=0;i<n;i++)
 		{
 			
 			String s=str.substring(i,i+1);
 			int x=Integer.parseInt(s);
 			temp=temp+x;
 		}
 		if(temp%9==0)System.out.println("Yes");
 		else System.out.println("No");
 	} Scanner sc=new Scanner (System.in); sc new Scanner (System.in) String str=sc.next(); str sc.next() sc.next sc int n=str.length(); n str.length() str.length str int i i temp=0; temp 0 for(i=0;i<n;i++)
 		{
 			
 			String s=str.substring(i,i+1);
 			int x=Integer.parseInt(s);
 			temp=temp+x;
 		} i=0; i=0 i 0 i<n i n i++ i++ i {
 			
 			String s=str.substring(i,i+1);
 			int x=Integer.parseInt(s);
 			temp=temp+x;
 		} {
 			
 			String s=str.substring(i,i+1);
 			int x=Integer.parseInt(s);
 			temp=temp+x;
 		} String s=str.substring(i,i+1); s str.substring(i,i+1) str.substring str i i+1 i 1 int x=Integer.parseInt(s); x Integer.parseInt(s) Integer.parseInt Integer s temp=temp+x temp temp+x temp x if(temp%9==0)System.out.println("Yes");
 		else System.out.println("No"); temp%9==0 temp%9 temp 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 sc=new Scanner (System.in);
 		//int t=sc.nextInt();
 		String str=sc.next();
 		int n=str.length();
 		int i,temp=0;
 		for(i=0;i<n;i++)
 		{
 			
 			String s=str.substring(i,i+1);
 			int x=Integer.parseInt(s);
 			temp=temp+x;
 		}
 		if(temp%9==0)System.out.println("Yes");
 		else System.out.println("No");
 	}
 } public class Main
 {
 	public static void main(String[]args)
 	{
 		Scanner sc=new Scanner (System.in);
 		//int t=sc.nextInt();
 		String str=sc.next();
 		int n=str.length();
 		int i,temp=0;
 		for(i=0;i<n;i++)
 		{
 			
 			String s=str.substring(i,i+1);
 			int x=Integer.parseInt(s);
 			temp=temp+x;
 		}
 		if(temp%9==0)System.out.println("Yes");
 		else System.out.println("No");
 	}
 } Main
 
 import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
 public class Main
 {
 	public static void main(String[]args)
 	{
 		Scanner sc=new Scanner (System.in);
 		//int t=sc.nextInt();
 		String str=sc.next();
 		int n=str.length();
 		int i,temp=0;
 		for(i=0;i<n;i++)
 		{
 			
 			String s=str.substring(i,i+1);
 			int x=Integer.parseInt(s);
 			temp=temp+x;
 		}
 		if(temp%9==0)System.out.println("Yes");
 		else System.out.println("No");
 	}
 }