A, B, C, D = input().strip().split(' ') A, B, C, D = int(A), int(B), int(C), int(D) print(min(B // C, D - B))