#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long long INF = 1e18;
const int MX = 2e5 + 10;
const int nx[4] = {0, 0, 1, -1}, ny[4] = {1, -1, 0, 0};
template <class T>
using V = vector<T>;
template <class T>
bool ckmin(T& a, const T& b) {
  return a > b ? a = b, 1 : 0;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, 1 : 0;
}
long long cdiv(long long a, long long b) {
  return a / b + ((a ^ b) > 0 && a % b);
}
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
long long random(long long a, long long b) { return a + rng() % (b - a + 1); }
void IO() {}
int N;
int solve(vector<int> a) {
  if ((int)a.size() <= 2) return (int)a.size();
  int bit = -1;
  for (auto x : a) {
    for (int j = (31) - 1; j >= (0); --j)
      if ((x) & ((1) << (j))) ckmax(bit, j);
  }
  vector<int> s, ss;
  for (auto x : a) {
    if ((x) & ((1) << (bit)))
      s.push_back(x);
    else
      ss.push_back(x);
  }
  if ((int)s.size() == 0 || (int)ss.size() == 0) {
    for (auto& x : a) x ^= ((1) << (bit));
    return solve(a);
  }
  return 1 + max(solve(s), solve(ss));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  IO();
  cin >> N;
  vector<int> a(N);
  for (int i = (0); i < (N); ++i) cin >> a[i];
  cout << N - solve(a) << "\n";
  return 0;
}
