import sys input = sys.stdin.readline N=int(input()) x=N//500 for i in range(x-2,10**9): now=i*500 if N-now<=100: print(i) break