#include <bits/stdc++.h>
using namespace std;
long long get_ans(vector<long long> arr, long long bit) {
  vector<long long> left_ans, right_ans;
  for (auto& x : arr) {
    if (x & (1 << bit)) {
      right_ans.push_back(x ^ (1 << bit));
    } else {
      left_ans.push_back(x);
    }
  }
  if (!bit) {
    return left_ans.size() + right_ans.size();
  }
  if (right_ans.empty()) {
    return get_ans(left_ans, bit - 1);
  }
  if (left_ans.empty()) {
    return get_ans(right_ans, bit - 1);
  }
  long long ans1 = get_ans(left_ans, bit - 1);
  long long ans2 = get_ans(right_ans, bit - 1);
  return max(1 + ans1, 1 + ans2);
}
void solve() {
  long long n;
  cin >> n;
  vector<long long> arr(n);
  for (auto& x : arr) {
    cin >> x;
  }
  cout << n - get_ans(arr, 31);
}
signed main() {
  solve();
  cout << '\n';
  return 0;
}
