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))