#include <bits/stdc++.h>
using namespace std;
using ll = long long;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
vector<int> V;
int solve(int L, int R, int bit) {
  if (bit == -1) return 1;
  if (L == R) return 1;
  if (((V[L] ^ V[R]) & (1 << bit)) == 0) return solve(L, R, bit - 1);
  int lo = L;
  int hi = R;
  while (hi - lo > 1) {
    int mid = int((hi + lo) / 2);
    if (((V[L] ^ V[mid]) & (1 << bit)) == 0)
      lo = mid;
    else
      hi = mid;
  }
  int ans1 = solve(L, lo, bit - 1);
  int ans2 = solve(hi, R, bit - 1);
  return 1 + max(ans1, ans2);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int v;
    cin >> v;
    V.push_back(v);
  }
  sort((V).begin(), (V).end());
  cout << n - solve(0, n - 1, 30) << endl;
}
