#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops", \
                     "omit-frame-pointer", "inline")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,fma,tune=native")
#pragma GCC option("arch=native", "no-zero-upper")
using namespace std;
const long long oo = (long long)(1e18);
int solve(vector<int>& a) {
  int n = a.size();
  vector<int> first[33];
  for (int i = 0; i < n; i++) {
    int x = a[i];
    int p = 0;
    while (x) {
      x /= 2;
      p++;
    }
    first[p].push_back(a[i]);
  }
  int res = 0;
  vector<int> ap;
  for (int i = 32; i >= 0; i--)
    if (first[i].size()) ap.push_back(i);
  reverse((ap).begin(), (ap).end());
  for (int i = 0; i < ap.size(); i++) {
    if (ap[i] == 0)
      res = max(res, (int)ap.size());
    else {
      for (auto& y : first[ap[i]]) y ^= (1 << (ap[i] - 1));
      res =
          max(res, solve(first[ap[i]]) + (int)ap.size() - i - 1 + (min(1, i)));
    }
  }
  return res;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  cout << (n - solve(a)) << '\n';
  return 0;
}
