#include <bits/stdc++.h>
using namespace std;
int solve(vector<int> &a, int msb) {
  if (a.empty()) return 0;
  if (msb == -1) return 1;
  vector<int> s0, s1;
  for (int x : a) {
    if (x >> msb & 1)
      s1.push_back(x);
    else
      s0.push_back(x);
  }
  return max(solve(s0, msb - 1) + !s1.empty(),
             solve(s1, msb - 1) + !s0.empty());
}
int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  cin.exceptions(cin.failbit);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  cout << n - solve(a, 30) << '\n';
}
