a, b, c, d = map(int, input().split()) for i in range(int(a), 0, -1): if b >= i * c and d >= a + b: print(i) exit() else: print("0") exit()