#include <bits/stdc++.h>
using namespace std;
int a[200005][35];
void dis(vector<int> v) {
  for (int i = 0; i < int(v.size()); i++) cout << v[i] << " ";
  cout << endl;
}
int f(int bit, vector<int> v) {
  if (int(v.size()) <= 2) return int(v.size());
  vector<vector<int>> g(35);
  for (int qc = 0; qc < int(v.size()); qc++) {
    int i = v[qc];
    for (int j = bit - 1; j >= 0; j--) {
      if (a[i][j]) {
        g[j].push_back(i);
        break;
      }
    }
  }
  int res = 0, lo = 35;
  for (int i = 0; i < 35; i++)
    if (!g[i].empty()) {
      lo = min(lo, i);
      res++;
    }
  int sum = res;
  for (int i = 0; i < 35; i++) {
    if (!g[i].empty()) {
      sum--;
      res = max(res, f(i, g[i]) + sum + (lo == i ? 0 : 1));
    }
  }
  return res;
}
void solve() {
  int n;
  cin >> n;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    v.push_back(i);
    a[i][0] = 1;
    int c = 1;
    while (x) {
      if (x & 1) a[i][c] = 1;
      x >>= 1;
      c++;
    }
  }
  cout << n - f(34, v);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  clock_t z = clock();
  int qc = 1;
  for (int i = 1; i <= qc; i++) solve();
  fprintf(stderr, "Total Time:%.4Lf\n",
          (long double)(clock() - z) / CLOCKS_PER_SEC),
      fflush(stderr);
}
