a, b, c, d = map(int, input().split()) s = 10**18 if a == 0 else c//a t = 10**18 if b == 0 else d//b print(min(s, t))