#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long N = 3e5 + 5;
const long long INF = 1e12;
long long f(vector<long long> &s, vector<long long> &a) {
  if (s.size() <= 2) {
    return s.size();
  }
  long long mostSignificantBit = 0;
  for (long long i = 0; i < s.size(); i++) {
    mostSignificantBit = max(mostSignificantBit, (long long)log2(a[s[i]]));
  }
  vector<long long> s0, s1;
  for (long long i = 0; i < s.size(); i++) {
    if (a[s[i]] & (1 << mostSignificantBit)) {
      s1.push_back(s[i]);
    } else {
      s0.push_back(s[i]);
    }
    a[s[i]] = a[s[i]] & ~(1 << mostSignificantBit);
  }
  if (s0.size() == 0 || s1.size() == 0) {
    return f(s, a);
  } else {
    return 1 + max(f(s0, a), f(s1, a));
  }
}
void solve() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  vector<long long> s(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    s[i] = i;
  }
  long long ans = n - f(s, a);
  cout << ans << "\n";
  return;
}
int main() {
  ios::sync_with_stdio(false);
  int t;
  for (long long i = 0; i < 1; i++) {
    solve();
  }
  return 0;
}
