program ABC176B
    implicit none
    integer(8)::i,ans=0
    character(2000000)::S
    read*,S
    do i=1,len_trim(S)
        ans=ans+ichar(S(i:i))-48
    end do
    
    if(mod(ans,9)==0)then
        print'(A)',"Yes"
    else
        print'(A)',"No"
    end if
end program ABC176B