#include <bits/stdc++.h>
using namespace std;
const long long N = 2e6 + 7, M = (long long)1e9 + 7, inf = INT_MAX;
const long long INF = LLONG_MAX;
long long setBitNumber(long long n) {
  long long msb = -1;
  while (n != 0) {
    n = n / 2;
    msb++;
  }
  return msb;
}
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  if (0) return;
  cout << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  if (0) return;
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
long long getans(vector<long long> vec, long long b) {
  long long sz = vec.size();
  if (sz <= 2) return sz;
  vector<long long> nvec[32];
  long long ans = 0, cnt = 0, flag = 0;
  for (auto i : vec) {
    if (!i) {
      flag = 2;
      cnt = 1;
      continue;
    }
    long long k = setBitNumber(i);
    i ^= (1LL << k);
    nvec[k].push_back(i);
  }
  vector<long long> arr(32, 0);
  for (long long i = 30; i >= 0; i--) {
    long long sz = nvec[i].size();
    if (sz == 0) continue;
    arr[i] = arr[i + 1] + 1;
  }
  for (long long i = 0; i < (long long)31; i++) {
    long long sz = nvec[i].size();
    if (sz == 0) continue;
    long long val = getans(nvec[i], b - 1) + arr[i + 1];
    if (cnt) val++;
    ans = max(ans, val);
    cnt++;
  }
  ans = max(ans, cnt);
  return ans;
}
void solve() {
  long long n;
  cin >> n;
  vector<long long> vec(n);
  for (long long i = 0; i < n; i++) cin >> vec[i];
  long long result = getans(vec, 30);
  cout << n - result << '\n';
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long test = 1;
  while (test--) solve();
}
