#include <bits/stdc++.h>
using namespace std;
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};
int recurse(vector<long long int> &v, int j) {
  if (v.size() == 0) return 0;
  if (v.size() == 1) return 1;
  long long int mask = (1LL << j);
  vector<long long int> zero;
  vector<long long int> one;
  for (int i = 0; i < v.size(); i++) {
    if ((v[i] & mask) == mask) {
      one.push_back(v[i]);
    } else {
      zero.push_back(v[i]);
    }
  }
  if (one.size() == 0)
    return recurse(zero, j - 1);
  else if (zero.size() == 0)
    return recurse(one, j - 1);
  else
    return (1 + max(recurse(one, j - 1), recurse(zero, j - 1)));
}
void solve() {
  int n;
  cin >> n;
  vector<long long int> a;
  int i;
  for (i = 0; i < n; i++) {
    long long int temp;
    cin >> temp;
    a.push_back(temp);
  }
  cout << (n - recurse(a, 30)) << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
}
