#include <bits/stdc++.h>
using namespace std;
long long dp[200002];
long long find(vector<long long> &a, long long pos) {
  long long n = a.size();
  if (pos < 0) return 0;
  if (n == 1) return 1;
  if (n == 2) return 2;
  if (n == 0) return 0;
  vector<long long> left;
  vector<long long> right;
  for (long long i = 0; i < n; i++) {
    long long f = 1 << pos;
    if (f & a[i])
      right.push_back(a[i]);
    else
      left.push_back(a[i]);
  }
  long long lans = find(left, pos - 1);
  long long rans = find(right, pos - 1);
  return max(lans + ((rans) ? 1 : 0), rans + ((lans) ? 1 : 0));
}
void solve() {
  long long n;
  cin >> n;
  vector<long long> arr;
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x;
    arr.push_back(x);
  }
  long long ans = find(arr, 30);
  cout << n - ans << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
