program Multipleof
    implicit none
    integer(8) n
    integer,allocatable :: m(:)

    read *,n
    if(mod(n,9)==0) then
        allocate(m(n))
        if(mod(sum(m),9)==0) then
            print *,"Yes"
        end if
    else
        print *,"No"
    end if
end program Multipleof