a, b, c, d = map(int, input().split()) i = 0 while i <= a and i*c <= b and (i + i*c) <= d: i += 1 print(i-1)