yasai,b,c,d = map(int,input().split()) niku = b // c kumi = min(yasai,niku) size = 1 + c ryou = d // size print(min(ryou,kumi))