Calculating maximum number of days within a budget