#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int mod1 = 998244353;
const long long inf = 5e18;
const int nax = 200005;
int n, a[nax];
int find_best(int l, int r, int bit) {
  if (bit == -1) return r - l + 1;
  int pos = l;
  while (pos <= r && !(a[pos] & (1 << bit))) pos++;
  if (pos == l || pos > r)
    return find_best(l, r, bit - 1);
  else
    return max(find_best(l, pos - 1, bit - 1), find_best(pos, r, bit - 1)) + 1;
}
void solve() {
  cin >> n;
  for (int i = (0); i < (n); i++) cin >> a[i];
  sort(a, a + n);
  cout << (n - find_best(0, n - 1, 30));
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
}
