a,b,c,d=map(int,input().split()) if not a: print(d//b) elif not b: print(c//a) else: print(min(c//a,d//b))