program B176
implicit none
character(200000) :: N
integer(8) :: sum = 0
integer(8) :: len
integer(8) :: i
integer(8) :: num
read(5,*) N
len=len_trim(N)

do i = 1,len
	
    read(N(i:i),*)num
	sum = sum + num
end do

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


end program B176
