program multiple_of_9
  implicit none
  character(200000) :: s
  integer :: n = 0, i
  read(*,'(a)') s
  do i = 1, len_trim(s)
    n = n + ichar(s(i:i)) - 48
  end do
  write(*,'(a)') trim(merge('Yes', 'No ', mod(n, 9) == 0))
end program multiple_of_9