#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, m, k, now, sum;
int ans;
struct node {
int w, a;
bool operator> (const node &T) const {
return w < T.w;
}
bool operator< (const node &T) const {
return w > T.w;
}
} b[N];
map<int, int> mp;
priority_queue<node, vector<node>, greater<node> > lm;
signed main() {
scanf("%d%d%d", &n, &m, &k);
for(int i = 1; i <= n; i++) {
scanf("%d%d", &b[i].w, &b[i].a);
}
sort(b + 1, b + n + 1);
lm.push({b[1].w, min(b[1].a, m)});
sum = m;
ans += min(b[1].a, m), now = 1, sum -= min(b[1].a, m);
while(!lm.empty()) {
now++;
if(now == n + 1) break;
while(!lm.empty() && b[now].a) {
node f = lm.top();
lm.pop();
int tmp = f.w;
if(f.w - b[now].w >= k) {
if(b[now].a >= f.a) {
f.w = b[now].w;
ans += f.a;
b[now].a -= f.a;
} else {
f.a = f.a - b[now].a;
lm.push(f);
f.a = b[now].a;
f.w = b[now].w;
ans += b[now].a;
b[now].a = 0;
}
}
lm.push(f);
if(tmp - b[now].w < k) break;
}
if(sum && b[now].a) {
int tmp = b[now].a;
lm.push({b[now].w, min(b[now].a, sum)});
ans += min(b[now].a, sum);
b[now].a -= min(b[now].a, sum);
sum -= min(tmp, sum);
}
}
printf("%d", ans);
return 0;
}