import java.util.*;
class Main{
 static int help(int a){
 int s=a;
    while(s>91){
      int p=0;
      while(a>0){
        p=p+a%10;
        a=a/10;
      }
      s=p;
    }
   return s;
  }
  public static void main(String args[]){
    Scanner sc=new Scanner(System.in);
   String n=sc.nextLine();
    int a=0;
    for(int i=0;i<n.length();i++){
    a=a+n.charAt(i)-'0';
     
    }
    if(a<91){
      if(a%9==0){
      System.out.println("Yes");
      }else{
        System.out.println("No");
      }}
    
    else{
      int b=help(a);
         if(b%9==0){
      System.out.println("Yes");
      }else{
        System.out.println("No");
      }
   
  }}} import java.util.*; util.* java class Main{
 static int help(int a){
 int s=a;
    while(s>91){
      int p=0;
      while(a>0){
        p=p+a%10;
        a=a/10;
      }
      s=p;
    }
   return s;
  }
  public static void main(String args[]){
    Scanner sc=new Scanner(System.in);
   String n=sc.nextLine();
    int a=0;
    for(int i=0;i<n.length();i++){
    a=a+n.charAt(i)-'0';
     
    }
    if(a<91){
      if(a%9==0){
      System.out.println("Yes");
      }else{
        System.out.println("No");
      }}
    
    else{
      int b=help(a);
         if(b%9==0){
      System.out.println("Yes");
      }else{
        System.out.println("No");
      }
   
  }}} Main static int help(int a){
 int s=a;
    while(s>91){
      int p=0;
      while(a>0){
        p=p+a%10;
        a=a/10;
      }
      s=p;
    }
   return s;
  } help {
 int s=a;
    while(s>91){
      int p=0;
      while(a>0){
        p=p+a%10;
        a=a/10;
      }
      s=p;
    }
   return s;
  } int s=a; s a while(s>91){
      int p=0;
      while(a>0){
        p=p+a%10;
        a=a/10;
      }
      s=p;
    } s>91 s 91 {
      int p=0;
      while(a>0){
        p=p+a%10;
        a=a/10;
      }
      s=p;
    } int p=0; p 0 while(a>0){
        p=p+a%10;
        a=a/10;
      } a>0 a 0 {
        p=p+a%10;
        a=a/10;
      } p=p+a%10 p p+a%10 p a%10 a 10 a=a/10 a a/10 a 10 s=p s p return s; s int a a public static void main(String args[]){
    Scanner sc=new Scanner(System.in);
   String n=sc.nextLine();
    int a=0;
    for(int i=0;i<n.length();i++){
    a=a+n.charAt(i)-'0';
     
    }
    if(a<91){
      if(a%9==0){
      System.out.println("Yes");
      }else{
        System.out.println("No");
      }}
    
    else{
      int b=help(a);
         if(b%9==0){
      System.out.println("Yes");
      }else{
        System.out.println("No");
      }
   
  }} main {
    Scanner sc=new Scanner(System.in);
   String n=sc.nextLine();
    int a=0;
    for(int i=0;i<n.length();i++){
    a=a+n.charAt(i)-'0';
     
    }
    if(a<91){
      if(a%9==0){
      System.out.println("Yes");
      }else{
        System.out.println("No");
      }}
    
    else{
      int b=help(a);
         if(b%9==0){
      System.out.println("Yes");
      }else{
        System.out.println("No");
      }
   
  }} Scanner sc=new Scanner(System.in); sc new Scanner(System.in) String n=sc.nextLine(); n sc.nextLine() sc.nextLine sc int a=0; a 0 for(int i=0;i<n.length();i++){
    a=a+n.charAt(i)-'0';
     
    } int i=0; int i=0; i 0 i<n.length() i n.length() n.length n i++ i++ i {
    a=a+n.charAt(i)-'0';
     
    } {
    a=a+n.charAt(i)-'0';
     
    } a=a+n.charAt(i)-'0' a a+n.charAt(i)-'0' a+n.charAt(i) a n.charAt(i) n.charAt n i '0' if(a<91){
      if(a%9==0){
      System.out.println("Yes");
      }else{
        System.out.println("No");
      }}
    
    else{
      int b=help(a);
         if(b%9==0){
      System.out.println("Yes");
      }else{
        System.out.println("No");
      }
   
  } a<91 a 91 {
      if(a%9==0){
      System.out.println("Yes");
      }else{
        System.out.println("No");
      }} if(a%9==0){
      System.out.println("Yes");
      }else{
        System.out.println("No");
      } a%9==0 a%9 a 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" {
      int b=help(a);
         if(b%9==0){
      System.out.println("Yes");
      }else{
        System.out.println("No");
      }
   
  } int b=help(a); b help(a) help a if(b%9==0){
      System.out.println("Yes");
      }else{
        System.out.println("No");
      } b%9==0 b%9 b 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
import java.util.*;
class Main{
 static int help(int a){
 int s=a;
    while(s>91){
      int p=0;
      while(a>0){
        p=p+a%10;
        a=a/10;
      }
      s=p;
    }
   return s;
  }
  public static void main(String args[]){
    Scanner sc=new Scanner(System.in);
   String n=sc.nextLine();
    int a=0;
    for(int i=0;i<n.length();i++){
    a=a+n.charAt(i)-'0';
     
    }
    if(a<91){
      if(a%9==0){
      System.out.println("Yes");
      }else{
        System.out.println("No");
      }}
    
    else{
      int b=help(a);
         if(b%9==0){
      System.out.println("Yes");
      }else{
        System.out.println("No");
      }
   
  }}}
