program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,p

    read*, n
    p=0
    do while(p < n)
        p=p+1000
    end do

    print'(i0)', p-n
end program main