import java.util.*;
import java.lang.*;
import java.math.BigInteger;
public class Main{
  public static void main(String arg[])
  {
   Scanner sc=new Scanner(System.in);
   
   BigInteger b=sc.nextBigInteger();
   BigInteger x=b.mod(new BigInteger("9"));
   if(x.equals(new BigInteger("0")))System.out.println("Yes");
   else System.out.println("No");
    
  }
} import java.util.*; util.* java import java.lang.*; lang.* java import java.math.BigInteger; BigInteger java.math public class Main{
  public static void main(String arg[])
  {
   Scanner sc=new Scanner(System.in);
   
   BigInteger b=sc.nextBigInteger();
   BigInteger x=b.mod(new BigInteger("9"));
   if(x.equals(new BigInteger("0")))System.out.println("Yes");
   else System.out.println("No");
    
  }
} Main public static void main(String arg[])
  {
   Scanner sc=new Scanner(System.in);
   
   BigInteger b=sc.nextBigInteger();
   BigInteger x=b.mod(new BigInteger("9"));
   if(x.equals(new BigInteger("0")))System.out.println("Yes");
   else System.out.println("No");
    
  } main {
   Scanner sc=new Scanner(System.in);
   
   BigInteger b=sc.nextBigInteger();
   BigInteger x=b.mod(new BigInteger("9"));
   if(x.equals(new BigInteger("0")))System.out.println("Yes");
   else System.out.println("No");
    
  } Scanner sc=new Scanner(System.in); sc new Scanner(System.in) BigInteger b=sc.nextBigInteger(); b sc.nextBigInteger() sc.nextBigInteger sc BigInteger x=b.mod(new BigInteger("9")); x b.mod(new BigInteger("9")) b.mod b new BigInteger("9") if(x.equals(new BigInteger("0")))System.out.println("Yes");
   else System.out.println("No"); x.equals(new BigInteger("0")) x.equals x new BigInteger("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 arg[] arg public class Main{
  public static void main(String arg[])
  {
   Scanner sc=new Scanner(System.in);
   
   BigInteger b=sc.nextBigInteger();
   BigInteger x=b.mod(new BigInteger("9"));
   if(x.equals(new BigInteger("0")))System.out.println("Yes");
   else System.out.println("No");
    
  }
} public class Main{
  public static void main(String arg[])
  {
   Scanner sc=new Scanner(System.in);
   
   BigInteger b=sc.nextBigInteger();
   BigInteger x=b.mod(new BigInteger("9"));
   if(x.equals(new BigInteger("0")))System.out.println("Yes");
   else System.out.println("No");
    
  }
} Main
import java.util.*;
import java.lang.*;
import java.math.BigInteger;
public class Main{
  public static void main(String arg[])
  {
   Scanner sc=new Scanner(System.in);
   
   BigInteger b=sc.nextBigInteger();
   BigInteger x=b.mod(new BigInteger("9"));
   if(x.equals(new BigInteger("0")))System.out.println("Yes");
   else System.out.println("No");
    
  }
}