program B176
implicit none
character(200000) :: N
integer(8) :: i, j, sum, len


read(5,*) N
len = len_trim(N)
sum = 0
do i = 1, len
    read(N(i:i),*) j
    sum = sum + j

end do

if (mod(sum,9) == 0) then
    write(6,*) "Yes"
else
    write(6,*) "No"
end if



end program B176