#include <bits/stdc++.h>
using namespace std;
long long dir[4][2] = {1, 0, -1, 0, 0, 1, 0, -1};
int find(vector<int> &a, int b) {
  if (b < 0) return 1;
  vector<int> b0, b1;
  for (long long i = 0; i < a.size(); i++) {
    if (a[i] & (1 << b))
      b1.push_back(a[i]);
    else
      b0.push_back(a[i]);
  }
  if (b0.size() == 0)
    return find(b1, b - 1);
  else if (b1.size() == 0)
    return find(b0, b - 1);
  else
    return 1 + max(find(b0, b - 1), find(b1, b - 1));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t = 1;
  while (t--) {
    long long n;
    cin >> n;
    vector<int> v(n);
    for (long long i = 0; i < n; i++) cin >> v[i];
    cout << n - find(v, 29) << endl;
  }
  return 0;
}
