input_params = list(map(int,input().split())) a = input_params[0] b = input_params[1] c = input_params[2] d = input_params[3] subres = [0] for i in range(a): vnum = i + 1 if c * vnum <= b and (c + 1) * vnum <= d: subres.append(vnum) res = max(subres) print(res)