n, t, s = gets.split.map &:to_i
s = t - s if 2 * s < t

items = $<.map{|s| s.split.reverse.map &:to_i}

table = (0..1).map { (0..s).map{|g| [0] * ((g < t-s ? g : t-s) + 1)} }
for k in 0..items.size-1
	c, v = items[k]
	for i in 0..s
		j_max = (i < t-s ? i : t-s)
		for j in 0..j_max
			cand = []
			cand << table[0][i][j]
			cand << table[0][i][j-c] + v if j >= c
			y, x = i-c, j
			y, x = x, y if x > y
			cand << table[0][y][x] + v if i >= c
			table[1][i][j] = cand.max
		end
	end
	table << table.shift
end
p table[-1][s][t-s]