A, B, C, D = map(int, input().split()) for i in range(1010): if i <= A and i*C <= B and i+i*C <= D: continue print(i-1) exit()