#include <bits/stdc++.h>
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
bool debug = false;
int main() {
  int ans = 0;
  int n, a, b;
  int imos[100005] = {0};
  cin >> n;
  for (int i = 0; i < int(n); i++) {
    scanf("%d%d", &a, &b);
    imos[a]++;
    imos[b + 1]--;
  }
  for (int i = (1); i < int(n + 1); i++) {
    imos[i] += imos[i - 1];
    if (imos[i] >= ans) ans = imos[i] - 1;
  }
  if (ans > 0)
    printf("%d\n", ans);
  else
    printf("0\n");
  return 0;
}
