program main
 
 implicit none
 integer::leng,ans,i,j
 character::num*200000,a*1
 integer,allocatable::n(:)

 read*,num
 !print*,num
 leng=len_trim(num)
 !print*,leng
 allocate(n(leng))

 do i=1,leng
  a=num(i:i)
  read(a,*) n(i)
  !print*,n(i)
 end do


ans=0
 do j=1,leng
   ans=ans+n(j)
 end do
 
 if(mod(ans,9)==0) then
  print*,'Yes'
 else
  print*,'No'
 end if

end program main
  