char = input().split(" ") a = int(char[0]) b = int(char[1]) c = int(char[2]) d = int(char[3]) vegi_list = [0] for vegi in range(d + 1): meat = d - vegi if meat >= vegi * c and vegi + meat <= d: vegi_list.append(vegi) print(max(vegi_list))