#include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
long long solve(vector<long long> arr, long long val) {
  vector<long long> one, zero;
  if (val < 0 || arr.size() == 0) return 0;
  if (arr.size() <= 2) return arr.size();
  for (long long i = 0; i < arr.size(); i++) {
    long long k = arr[i] >> val & 1;
    if (k == 0)
      zero.push_back(arr[i]);
    else
      one.push_back(arr[i]);
  }
  long long ans = 1;
  if (one.size() == 0 || zero.size() == 0) ans = 0;
  return ans + max(solve(zero, val - 1), solve(one, val - 1));
}
int32_t main() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  cout << n - solve(a, 31) << endl;
}
