#include <cstdio>
#include <set>
#include <vector>
#include <algorithm>
#define s second
#define f first
using namespace std;
multiset <int> h;
vector <pair<int,int> > a;
pair <int,int> o;
multiset <int>::iterator it;
using namespace std;
int x,i,sol,l,j,poz,lan,n,timp;
int main()
{
freopen("lupu.in","r",stdin);
freopen("lupu.out","w",stdout);
scanf("%d %d %d",&n,&x,&l);
for(i=1; i<=n; i++)
{
scanf("%d %d",&poz,&lan);
if(poz<=x)
{
timp=(x-poz)/l+1;
a.push_back(make_pair(timp,lan));
}
}
sort(a.begin(), a.end());
reverse(a.begin(), a.end());
o=*(a.begin());
j=o.f;
i=0;
for(i=j; i>=1; i--)
{
if(a[i].f==i)
{
h.insert(a[i].s);
}
else{
it=h.end();
it--;
sol+=*it;
h.erase(it);
}
}
return 0;
}