inpu = list(map(int,input().rstrip().split(' '))) BegiNum = 0 Begi = inpu[0] Meat = inpu[1] while(inpu[2] + 1 < inpu[3] and Begi > 0 and Meat - inpu[2] > 0): BegiNum = BegiNum + 1 Begi = Begi - 1 Meat = Meat - inpu[2] inpu[3] = inpu[3] - inpu[2] - 1 print(BegiNum)