#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
const int N = 1e5 + 10;
struct lulu
{
int time1 = 0;
int time2 = 0;
int lev;
} sal[N];
struct dudu
{
int t;
int id;
} putin[N];
bool cmp(struct dudu a, struct dudu b)
{
return a.t < b.t;
}
int ans[N];
int res = 0;
int main()
{
int n, m, T;
cin >> n >> m >> T;
for (int i = 1; i <= m; i++)
cin >> putin[i].t >> putin[i].id;
sort(putin + 1, putin + m + 1, cmp);
for (int i = 1; i <= m; i++)
{
sal[putin[i].id].time2 = putin[i].t;
if (sal[putin[i].id].time1 == 0 || sal[putin[i].id].time2 - sal[putin[i].id].time1 <= 1)
goto end;
int chuchu;
chuchu = abs(sal[putin[i].id].time2 - sal[putin[i].id].time1 - 1);
if (sal[putin[i].id].lev > chuchu)
sal[putin[i].id].lev -= chuchu;
else
sal[putin[i].id].lev = 0;
sal[putin[i].id].time1 = sal[putin[i].id].time2;
if (sal[putin[i].id].lev > 5)
ans[putin[i].id] = 1;
else if (sal[putin[i].id].lev <= 3)
ans[putin[i].id] = 0;
end:
{
sal[putin[i].id].lev += 2;
sal[putin[i].id].time1 = sal[putin[i].id].time2;
if (sal[putin[i].id].lev > 5)
ans[putin[i].id] = 1;
else if (sal[putin[i].id].lev <= 3)
ans[putin[i].id] = 0;
}
}
for (int i = 1; i <= n; i++)
{
int tmp = T - sal[i].time1;
sal[i].lev -= tmp;
if (sal[i].lev <= 3)
ans[i] = 0;
if (ans[i] == 1)
res++;
}
cout << res << endl;
return 0;
}