program abc45
 implicit none
 character(len=200000)::N
 integer,allocatable::a(:)
 integer::len,ia,s
 read(*,*)N
 len=len_trim(N)
 allocate(a(len))
 do ia=1,len
  read(N(ia:ia),*)a(ia)
 end do
 s=sum(a)
 if(mod(s,9)==0)then
  print'(a)',"Yes"
 else
  print'(a)',"No"
 end if
end program abc45