program number_div
	implicit none
	character(200000)::s
    character(3):: ans
    integer:: i, n, idx
    
    
    read(*,*) s
    n = 0
	do i = 1, len(trim(s))
        n = n + iachar(s(i:i))-iachar('0')
    end do
    if (mod(n,9) == 0) then; ans = 'Yes'; else; ans = 'No'; endif
    write(*,'(a)') ans
end program
