A, B, C, D = map(int, input().split()) for x in range(A, 0, -1): if x*C<=B and x+x*C<=D: print(x) break if x==1: print(0)