A, B, C, D = input().split() A, B, C, D = int(A), int(B), int(C), int(D) res, su = 0, 0 for i in range(1, D): if i % 2 != 0: meet = C vegi = 0 su += meet B -= C else: res += 1 su += 1 A -= 1 if su > D or A < 0 or B < 0: break print(res)