#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = double;
const ll MODBASE = 1000000007LL;
const int MAXN = 200010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;
int n, a[MAXN];
int solve(int l, int r, int pos) {
  if (l > r) return 0;
  if (pos == 0) return r - l + 1;
  int num0 = 0, num1 = 0, first = 0;
  for (int i = (l); i <= (r); i++)
    if (a[i] & (1 << pos)) {
      if (!first) first = i;
      num1++;
    } else {
      num0++;
    }
  pair<int, int> lef = pair<int, int>(l, first - 1);
  pair<int, int> rig = pair<int, int>(first, r);
  if (num0 == r - l + 1) return solve(l, r, pos - 1);
  if (num1 == r - l + 1) return solve(l, r, pos - 1);
  int g = solve(lef.first, lef.second, pos - 1);
  int h = solve(rig.first, rig.second, pos - 1);
  if (g > h)
    return g + 1;
  else
    return h + 1;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(nullptr);
  cin >> n;
  for (int i = (1); i <= (n); i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  cout << n - solve(1, n, 29);
  return 0;
}
