#include <bits/stdc++.h>
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int ddx[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
bool debug = false;
void solve(int n) {
  int a, b;
  vector<int> imos(100005, 0);
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    imos[a]++;
    imos[b + 1]--;
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    imos[i] += imos[i - 1];
    ans = max(ans, imos[i]);
  }
  cout << ans - 1 << endl;
}
int main() {
  int n;
  while (cin >> n) {
    solve(n);
  }
  return 0;
}
