#include <bits/stdc++.h>
using namespace std;
#pragma optimize("-O3")
const int N = 2e5 + 5;
int arr[N];
int n;
int first(vector<int> v, int ind) {
  if (v.empty()) {
    return 0;
  }
  if (ind == -1) {
    return int(v.size());
  }
  vector<int> v1;
  vector<int> v2;
  for (auto u : v) {
    if ((u & (1 << ind))) {
      v1.push_back(u);
    } else {
      v2.push_back(u);
    }
  }
  if (v1.empty()) {
    return first(v2, ind - 1);
  }
  if (v2.empty()) {
    return first(v1, ind - 1);
  }
  return 1 + max(first(v1, ind - 1), first(v2, ind - 1));
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    v.push_back(arr[i]);
  }
  cout << n - first(v, 30) << '\n';
  return 0;
}
