def unbounded_knapsack(items, budget)
	table = [0]
	for i in 1..budget
		table[i] = 0
		items.each{|c, v|
			next if c > i
			x = table[i-c] + v
			table[i] = x if x > table[i]
		}
	end
	table[budget]
end

n_stock, n_day, budget = gets.split.map &:to_i

price = (1..n_day).map{ gets.split.map &:to_i }

price.each_cons(2){|a, b|
	cost_profit = a.zip(b).map{|x, y| [x, [y - x, 0].max]}
	budget += unbounded_knapsack(cost_profit, budget)
}
p budget