#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int solve(vector<int> &a, int bit) {
  if (a.size() <= 3) return (int)a.size();
  vector<int> a1, a2;
  for (int i : a) {
    if (i & (1 << bit)) {
      a1.push_back(i);
    } else
      a2.push_back(i);
  }
  if (a2.size() == 0) return solve(a1, bit - 1);
  if (a1.size() == 0) return solve(a2, bit - 1);
  return max(solve(a1, bit - 1), solve(a2, bit - 1)) + 1;
}
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int &i : a) cin >> i;
  cout << n - solve(a, 30);
  return 0;
}
