A, B, C, D = map(int, input().split()) INF = 1<<60 if A == 0: a = INF else: a = C//A if B == 0: b = INF else: b = D//B print(min(a, b))