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