
/*
 *   
 *   Date: 07 September 2019
 *   Time: 01:03:00
*/
import java.io.*; 
import java.util.*;


   
 class Main 
{   
 static boolean check(String str) 
    { 
        long n = str.length(); 
        long digitSum = 0; 
        for (int i=0; i<n; i++) 
            digitSum += (str.charAt(i)-'0'); 
       
        return (digitSum % 9 == 0); 
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
         String s=sc.next();
         if(check(s)){
         	System.out.println("Yes");
         }else{
         	System.out.println("No");
         }
        
       

       
    } 
} 
 
 
  import java.io.*; io.* java import java.util.*; util.* java class Main 
{   
 static boolean check(String str) 
    { 
        long n = str.length(); 
        long digitSum = 0; 
        for (int i=0; i<n; i++) 
            digitSum += (str.charAt(i)-'0'); 
       
        return (digitSum % 9 == 0); 
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
         String s=sc.next();
         if(check(s)){
         	System.out.println("Yes");
         }else{
         	System.out.println("No");
         }
        
       

       
    } 
} Main static boolean check(String str) 
    { 
        long n = str.length(); 
        long digitSum = 0; 
        for (int i=0; i<n; i++) 
            digitSum += (str.charAt(i)-'0'); 
       
        return (digitSum % 9 == 0); 
    } check { 
        long n = str.length(); 
        long digitSum = 0; 
        for (int i=0; i<n; i++) 
            digitSum += (str.charAt(i)-'0'); 
       
        return (digitSum % 9 == 0); 
    } long n = str.length(); n str.length() str.length str long digitSum = 0; digitSum 0 for (int i=0; i<n; i++) 
            digitSum += (str.charAt(i)-'0'); int i=0; int i=0; i 0 i<n i n i++ i++ i digitSum += (str.charAt(i)-'0'); digitSum += (str.charAt(i)-'0') digitSum (str.charAt(i)-'0') str.charAt(i) str.charAt str i '0' return (digitSum % 9 == 0); (digitSum % 9 == 0) digitSum % 9 digitSum 9 0 String str str public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
         String s=sc.next();
         if(check(s)){
         	System.out.println("Yes");
         }else{
         	System.out.println("No");
         }
        
       

       
    } main {
        Scanner sc = new Scanner(System.in);
         String s=sc.next();
         if(check(s)){
         	System.out.println("Yes");
         }else{
         	System.out.println("No");
         }
        
       

       
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s=sc.next(); s sc.next() sc.next sc if(check(s)){
         	System.out.println("Yes");
         }else{
         	System.out.println("No");
         } check(s) check s {
         	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

/*
 *   
 *   Date: 07 September 2019
 *   Time: 01:03:00
*/
import java.io.*; 
import java.util.*;


   
 class Main 
{   
 static boolean check(String str) 
    { 
        long n = str.length(); 
        long digitSum = 0; 
        for (int i=0; i<n; i++) 
            digitSum += (str.charAt(i)-'0'); 
       
        return (digitSum % 9 == 0); 
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
         String s=sc.next();
         if(check(s)){
         	System.out.println("Yes");
         }else{
         	System.out.println("No");
         }
        
       

       
    } 
} 
 
 
 
