#include <bits/stdc++.h>
using namespace std;
int solve(vector<int> a, int bit) {
  if (bit == 0) {
    return a.size();
  }
  if (a.size() <= 1) {
    return a.size();
  }
  vector<int> v0, v1;
  for (int x : a) {
    if (1 & (x >> bit)) {
      v0.push_back(x);
    } else {
      v1.push_back(x);
    }
  }
  return max(solve(v0, bit - 1) + (v1.size() ? 1 : 0),
             solve(v1, bit - 1) + (v0.size() ? 1 : 0));
}
int main() {
  int n;
  cin >> n;
  vector<int> arr(n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int ans = solve(arr, 30);
  cout << n - ans << endl;
  return 0;
}
