ans = 0 a,b = map(int, raw_input().split()) a -= 1 if (a % (b + 1) == 0): print 499 else: print 500