#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.sync_with_stdio(false);
  int n;
  cin >> n;
  int mini = INT_MAX / 3, maxi = 0;
  int num[100002] = {};
  for (int i = (int)(0); i < (int)(n); i++) {
    int a, b;
    cin >> a >> b;
    mini = min(mini, a), maxi = max(maxi, b + 1);
    num[a]++, num[b + 1]--;
  }
  int ans = 0, cnt = 0;
  for (int i = (int)(mini); i < (int)(min(n + 1, maxi)); i++)
    cnt += num[i], ans = max(ans, cnt);
  cout << ans - 1 << endl;
  return 0;
}
