#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int kemono[100001] = {};
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    for (int j = a; j <= b; ++j) kemono[j]++;
  }
  int ans = 0;
  ;
  for (int i = 0; i < 100001; ++i) {
    if (i <= n) ans = max(ans, kemono[i]);
  }
  if (ans)
    cout << ans - 1 << endl;
  else
    cout << 0 << endl;
  return 0;
}
