#include <bits/stdc++.h>
using namespace std;
int solve(int a[], int second, int e, int x) {
  if (second == e) {
    return 1;
  }
  int i;
  for (i = second; i <= e; i++) {
    if (a[i] >> x & 1) {
      break;
    }
  }
  int c = 0, b = 0;
  if (i - second > 0) {
    c = solve(a, second, i - 1, x - 1);
  }
  if (i <= e) {
    b = solve(a, i, e, x - 1);
  }
  if (c == 0 || b == 0) {
    return max(b, c);
  }
  return 1 + max(c, b);
}
int main() {
  long long int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  cout << n - solve(a, 0, n - 1, 30) << endl;
}
