program Multipleof
    implicit none
    character(len=200000) n
    integer(8) a,i,ans

    read *,n
    a=len_trim(n)
    ans=0
    do i=1,a
        if(n(i:i)=="1") then
            ans=ans+1
        else if(n(i:i)=="2") then
            ans=ans+2
        else if(n(i:i)=="3") then
            ans=ans+3
        else if(n(i:i)=="4") then
            ans=ans+4
        else if(n(i:i)=="5") then
            ans=ans+5
        else if(n(i:i)=="6") then
            ans=ans+6
        else if(n(i:i)=="7") then
            ans=ans+7
        else if(n(i:i)=="8") then
            ans=ans+8
        else if(n(i:i)=="9") then
            ans=ans+9
        end if
    end do
    if(mod(ans,9)==0) then
        print *,"Yes"
    else
        print *,"No"
    end if
end program Multipleof