#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int table[100005];
  int i, j;
  int n;
  int temp1, temp2;
  int max = 0;
  int count = 0;
  bool ha[100005];
  cin >> n;
  vector<int> a, b;
  for (i = 0; i < n; i++) {
    cin >> temp1 >> temp2;
    a.push_back(temp1);
    b.push_back(temp2);
  }
  for (i = 0; i < 100005; i++) {
    table[i] = 0;
  }
  sort(a.begin(), a.end());
  for (i = 0; i < n; i++) {
    if (a[i] > n) {
      a[i] = 100005 + 2;
    } else {
      count++;
    }
    if (count + 1 < a[0]) {
      cout << max << endl;
      return (0);
    }
  }
  for (i = 0; i < n; i++) {
    table[a[i]]++;
    table[b[i]]--;
  }
  for (i = 1; i < 100005; i++) {
    table[i] = table[i] + table[i - 1];
  }
  for (i = 0; i < 100005; i++) {
    if (max < table[i]) {
      max = table[i];
    }
  }
  cout << max << endl;
  return (0);
}
