A, B, C, D = map(int, input().split()) L = [] for a in range(A+1): if a + a*C <= D and a*C <= B: L += [a] print(max(L))