OI XV - pla

// https://szkopul.edu.pl/problemset/problem/au-E9FH96-3U9rCKhcNsD5n9/site/?key=statement
// OI XV (1 etap)

// Plakatowanie

#include <bitset>
#include <iostream>
#include <map>
#include <stack>
#include <unordered_map>

constexpr int sizik = 1000 * 1001;
constexpr int INF = 1001 * 1001 * 1001;

int tab[sizik];

int main() {
    std::ios_base::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.tie(0);

    int n;
    std::cin >> n;

    for (int i = 0; i < n; i++) {
        int a;
        std::cin >> a >> a;
        tab[i] = a;
    }

    tab[n] = 0;

    int ans = 1;

    std::stack<int> s;
    s.push(tab[0]);

    for (int i = 1; i < n; i++) {
        while (!s.empty() && s.top() > tab[i]) {
            s.pop();
        }

        if (!s.empty() && s.top() == tab[i]) {
            continue;
        } else {
            ans++;
            s.push(tab[i]);
        }
    }

    std::cout << ans << '\n';

    return 0;
}