#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
int solve(vector<int> a, int b) {
  if ((int)(a).size() <= 2 || !b) return (int)(a).size();
  vector<int> A, B;
  for (int i : a) {
    if (i & (1 << b))
      A.push_back(i);
    else
      B.push_back(i);
  }
  b--;
  if (A.empty()) return solve(B, b);
  if (B.empty()) return solve(A, b);
  return 1 + max(solve(A, b), solve(B, b));
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int& i : a) cin >> i;
  cout << n - solve(a, 30);
  return 0;
}
