def main(): a, b, c, d = map(int, input().split(' ')) vege = 0 meat = 0 st = d while vege < a and meat + c <= b and st - vege * (c + 1): vege += 1 meat = c * vege st -= vege + meat print(vege) if __name__ =='__main__': main()