A, B, C, D = map(int, input().split()) for i in range(1, A + 1): if i * C > B or i * C + i > D: print(i - 1) break else: print(A)