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