#include <bits/stdc++.h>
using namespace std;
long long calc(vector<long long> a) {
  vector<vector<long long>> b(31);
  long long n = a.size();
  if (n == 1) {
    return 1;
  }
  bool w = false;
  for (long long m = 29; m >= 0; m--) {
    bool f = true;
    for (long long i = 0; i < n && f; i++) {
      f &= ((a[i] >> m) & 1);
    }
    if (!f && w) {
      break;
    }
    if (f) {
      w = true;
      for (long long i = 0; i < n; i++) {
        a[i] ^= (1 << m);
      }
    }
  }
  for (long long i : a) {
    if (i == 0) {
      b[0].push_back(0);
      continue;
    }
    for (long long j = 29; j >= 0; j--) {
      if ((i >> j) & 1) {
        b[j + 1].push_back(i);
        break;
      }
    }
  }
  vector<vector<long long>> x;
  for (long long i = 0; i < 31; i++) {
    if (b[i].size()) {
      x.push_back(b[i]);
    }
  }
  long long r = x.size() - 1 + calc(x[0]);
  for (long long i = 1; i < x.size(); i++) {
    r = max(r, (long long)x.size() - i + calc(x[i]));
  }
  return r;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long &i : a) {
    cin >> i;
  }
  cout << n - calc(a) << endl;
  return 0;
}
