def main(): a, b, c, d = [int(x) for x in input().split(" ")] max_veg = 0 i = 0 while i <= a: sum = i + c * i if sum <= d and c * i < b: max_veg = i i += 1 print(max_veg) if __name__ == "__main__": main()