a,b,c,d=map(int,input().split())
k=0
u=a
while True:
	if u==0:
		break
	elif b<c:
		break
	elif (k+1+c)>d:
		break
	else:
		u,b=u-1,b-c
		k+=1+c
print(a-u)