a, b, c, d= map(int, input().split()) max = 0 for i in range(1,a+1): if (i*c <= b) and (i + b <= d): if max < i: max = i print(max)