n, t, s = gets.split.map &:to_i
items = $<.map{|s| s.split.map &:to_i}

table1 = [ Array.new(s+1, 0) ]
for k in 1..items.size
	table1 << [0] * (s+1)
	v, c = items[k-1]
	for i in 0..s
		table1[k][i] = table1[k-1][i]
		if i >= c
			x = table1[k-1][i-c] + v
			table1[k][i] = x if x > table1[k][i]
		end
	end
end

max = table1[-1][s]

table2 = (0..1).map{ Array.new(t-s+1, 0) }
k.times {|j|
	v, c = items.pop
	for i in 0..t-s
		table2[1][i] = table2[0][i]
		if i >= c
			x = table2[0][i-c] + v
			table2[1][i] = x if x > table2[1][i]
		end
	end
	table1.pop
	sum = table1[-1][s] + table2[1][t-s]
	max = sum if sum > max
	table2 << table2.shift
}

p max