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