#include <bits/stdc++.h>
using namespace std;
long long n, a[200010];
long long dividir(long long altura, vector<long long>& elemento) {
  if (altura < 0 or elemento.size() == 0) return elemento.size();
  vector<long long> tem0, tem1;
  for (long long i = 0; i < elemento.size(); i++) {
    if ((1 << altura) & a[elemento[i]])
      tem1.push_back(elemento[i]);
    else
      tem0.push_back(elemento[i]);
  }
  long long tam0 = tem0.size(), tam1 = tem1.size();
  long long esq = dividir(altura - 1, tem0), dir = dividir(altura - 1, tem1);
  if (tam1 >= 1) esq++;
  if (tam0 >= 1) dir++;
  return max(esq, dir);
}
void solve() {
  cin >> n;
  vector<long long> b;
  for (long long i = 1; i <= n; i++) cin >> a[i], b.push_back(i);
  cout << n - dividir(29, b);
}
signed main() { solve(); }
