#include <bits/stdc++.h>
using namespace std;
int r(vector<int> &v, int b) {
  if (v.size() < 3 or b < 0) return v.size();
  vector<int> on, off;
  for (int a : v)
    if ((1 << b) & a)
      on.push_back(a);
    else
      off.push_back(a);
  int x = r(on, b - 1);
  int y = r(off, b - 1);
  int ret = max(x, y) + !!min(x, y);
  return ret;
}
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int &v : a) cin >> v;
  cout << n - r(a, 30) << "\n";
}
