#include <iostream>
#include <cmath>
using namespace std;

int main(){
    int n;
    cin >> n;
    int x[n];
    int y[n];
    int i = 0;
    while(i < n){
        cin >> x[i] >> y[i];
        i++;
    }
    i = 0;
    int found;
    while (i < n) {
        if(found <= y[i]) {
            found = y[i];
        }
            i++;
    }
    int j = 0;
    int max1[y[i] * y[i];
    while (j < n - 1) {
        i = 0; int p = 0;
        while (i < n + 1) {
            max1[p] = 0;
            if (((x[i] >= j) && (x[i] < j + 1)) || ((y[i] > j) && (y[i] <= j + 1))) {
                max1[p] = max1[p] + 1; p++;
            }
            cout << max1[p - 1] << endl;
            i++;
            }
        j++;
    }
    int max = max1[0];
    int q = 0, r = 1;
    while (q < n * n) {
        if (max1[q] <= max1 [r]) {
            max = max1[r];
            q = r; r++;
        }
        else {
            r++;
        }
    }
    cout << max << endl;

    return 0;
}

