program main
    use,intrinsic :: iso_fortran_env
    implicit none
    character(200000):: cn
    integer(int32):: ds, i

    read*, cn

    ds = 0
    do i=1,len_trim(cn)
        ds=ds+(ichar(cn(i:i))-ichar("0"))
    end do

    if (mod(ds,9)==0) then
        print'(a)', 'Yes'
    else
        print'(a)', 'No'
    end if
    

end program main