#include <bits/stdc++.h>
using namespace std;
vector<long long> a;
bool f[200010];
long long ans = 0;
long long n;
long long iter(long long lay, vector<long long> mu) {
  if (mu.size() == 0) return 0;
  if (lay == -1) return mu.size();
  long long base = 1 << lay;
  vector<long long> a1;
  vector<long long> a2;
  for (auto x : mu) {
    if ((x & base) != 0)
      a1.push_back(x);
    else
      a2.push_back(x);
  }
  long long ans1 = iter(lay - 1, a1);
  long long ans2 = iter(lay - 1, a2);
  long long ans = max(ans1, ans2);
  if (min(ans1, ans2) != 0) ans++;
  return ans;
}
signed main() {
  memset(f, 0, sizeof(f));
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    long long x;
    scanf("%lld", &x);
    a.push_back(x);
  }
  long long answer = iter(31, a);
  cout << n - answer << endl;
}
