#include <bits/stdc++.h>
using namespace std;
long long mo(long long a) { return a % (long long)(1e9 + 7); }
long long po(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y >>= 1;
    x = (x * x) % p;
  }
  return res % p;
}
vector<long long> a;
long long solve(long long last_bit, vector<long long> &cur) {
  if (last_bit < 0) return 0;
  long long n = cur.size();
  vector<long long> ze, one;
  for (long long i = 0; i < n; i++) {
    if ((1LL << last_bit) & cur[i])
      one.push_back(cur[i]);
    else
      ze.push_back(cur[i]);
  }
  if (ze.size() == 0 || one.size() == 0)
    return solve(last_bit - 1, cur);
  else
    return 1 + max(solve(last_bit - 1, ze), solve(last_bit - 1, one));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  a.resize(n);
  for (long long i = 0; i < a.size(); i++) cin >> a[i];
  ;
  long long ans = solve(30, a);
  cout << n - ans - 1 << "\n";
  return 0;
}
