```ts
import { assert } from "assert";

export function fitBudget(prices: number[], budget: number): number {
    if (budget < 0) throw new Error("Amount to spend cannot be negative");
    prices.sort((a, b) => a - b);
    return prices.reduce((count, price) => count + Math.min(budget / price, 1), 0);
}
```