#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, sum1, sum2;
  int a[100100], b[100100];
  cin >> n;
  for (int h = 0; h < n; h++) {
    for (i = 0; i < n; i++) cin >> a[i] >> b[i];
    sort(a, a + n);
    sort(b, b + n);
    sum1 = 1;
    sum2 = 1;
    for (i = 1; i < n; i++) {
      if (a[i] != a[i - 1]) sum1++;
      if (b[i] != b[i - 1]) sum2++;
    }
  }
  if (sum1 < sum2)
    cout << sum1;
  else
    cout << sum2;
  return 0;
}
