a, b, c, d = map( int, input().split()) if b//c*(c+1) <= d: if a <= b//c: print(a) else: print(b//c) else: print(d//(c+1))