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