#include<cstdio>
#include<algorithm>
#include<functional>
#include<cstring>
#include<iostream>
#include<cmath>
#include<queue>
#include<cctype>
#include<string>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define INF 2100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define sz(x) ((int)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).begin(), (x).end(), greater<int>() )
#define clr(a,b) memset((a),(b),sizeof(a))
int dp[4545][4545],a[4545],b[4545];
int main(void)
{
	int n,t,s,time,mx=-1;
	cin>>n>>t>>s;
	rep(i,0,n) cin>>a[i]>>b[i];
	rep(i,0,n) rep(j,0,t+1) dp[i][j]=-1;
	dp[0][0]=0;
	rep(i,0,n) {
		rep(j,0,t+1) {
			if(dp[i][j]!=-1) {
				if(j<s && j+b[i]>s) time=((s-j)+(j+b[i]))-j;
				else time=b[i];
				if(i+1<=n)dp[i+1][j]=max(dp[i][j],dp[i+1][j]);
				if(i+1<=n&&j+time<=t)dp[i+1][j+time]=max(dp[i][j]+a[i],dp[i+1][j+time]);
			}
		}
	}
	/*rep(i,0,n) {
		rep(j,0,t) {
			printf("%5d",dp[i][j]);
		}
		cout<<endl;
	}*/
	rep(i,0,t+1) {
		mx=max(mx,dp[n][i]);
	}
	cout<<mx<<endl;
	return 0;
}
	
	