a, b, c, d = map(int, input().split()) x = 1 << 60 if a == 0 else c // a y = 1 << 60 if b == 0 else d // b print(min(x, y))