a,b,c,d = map(int,input().split()) if (a == 0) or (b == 0): print(max(c,d)) else: print( min( (c // a) , (d // b)) )