a, b, c, d = map(int, input().split()) print(min(c // a if a > 0 else float('inf'), d // b if b > 0 else float('inf')))