#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const long long int N = 2e5 + 5;
long long int Child[30 * N][2];
long long int Count[30 * N];
long long int Next = 0;
inline long long int dfs(long long int node = 0) {
  if (Count[node]) {
    return Count[node];
  }
  vector<long long int> v;
  for (long long int is : {0, 1}) {
    if (Child[node][is] != 0) {
      v.push_back(dfs(Child[node][is]));
    } else {
      v.push_back(0);
    }
  }
  return max(v[0] + min(1ll, v[1]), v[1] + min(1ll, v[0]));
}
void solve() {
  long long int n;
  cin >> n;
  vector<long long int> a(n);
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    long long int node = 0;
    for (long long int bit = 29; bit >= 0; bit--) {
      bool is = a[i] & (1ll << bit);
      if (Child[node][is] == 0) {
        Child[node][is] = ++Next;
      }
      node = Child[node][is];
    }
    Count[node]++;
  }
  cout << n - dfs() << '\n';
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  cerr << "Time : "
       << 1000 * ((long double)clock()) / (long double)CLOCKS_PER_SEC << "ms\n";
  return 0;
}
