a, b, c, d = map(int, input().split()) if b < c: print(0) else: t = b // c if a <= t: print(d - a - t * c) else: a = t print(d - a - t * c)