#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
int dfs(int index, vector<int> a) {
  if (a.empty()) return 0;
  if (index == 0) return a.size();
  vector<int> b, c;
  for (auto x : a) {
    if (x & (1 << index)) {
      b.push_back(x);
    } else
      c.push_back(x);
  }
  int k1 = dfs(index - 1, b);
  int k2 = dfs(index - 1, c);
  return max(k1, k2) + (min(k1, k2) > 0 ? 1 : 0);
}
int main() {
  using namespace std;
  ios_base::sync_with_stdio(false), cin.tie(nullptr);
  int n;
  while (cin >> n) {
    vector<int> a(n);
    vector<int> b[32];
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
    }
    cout << n - dfs(31, a) << endl;
  }
}
