#include <bits/stdc++.h>
using namespace std;
long long n;
long long solve(vector<long long> &arr, long long bitpos) {
  if (arr.size() <= 1) return arr.size();
  vector<long long> a, b;
  for (long long i = 0; i < arr.size(); i++) {
    if ((arr[i] & (1 << bitpos)) == 0)
      a.push_back(arr[i]);
    else
      b.push_back(arr[i]);
  }
  long long ans1 = solve(a, bitpos - 1);
  long long ans2 = solve(b, bitpos - 1);
  if (ans1 == 0) return ans2;
  if (ans2 == 0) return ans1;
  return max(ans1, ans2) + 1;
}
int32_t main() {
  cin >> n;
  vector<long long> arr(n);
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
  }
  long long a = solve(arr, 30);
  cout << n - a << "\n";
}
