#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<set>
#include<stack>
#include<map>
#define maxn 2500100
using namespace std;
long long n,ans=0;
stack<long long>q;
bool you[maxn];
int main() {
cin >> n;
long long k, h;
for (int i = 1; i <= n; ++i) {
cin >> k >> h;
ans++;
while (!q.empty()) {
if (q.top() > h) {
q.pop();
}
if (q.top() == h) {
ans--;
break;
}
if (q.top() < h) {
break;
}
}
q.push(h);
}
cout << ans;
return 0;
}
inline int read() {
int w = 1, q = 0;
char ch = ' ';
while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
if (ch == '-') w = -1, ch = getchar();
while (ch >= '0' && ch <= '9') q = q * 10 + ch - '0', ch = getchar();
return w * q;
}