a, b, c, d = [int(x) for x in input().split()] print(min([d // (c + 1), a, b // c]))