A, B, C, D = map(int, input().split()) if A == 0: print(D//B) elif B == 0: print(C//A) else: print(min(C//A, D//B))