#include <bits/stdc++.h>
using vi = std::vector<long long int>;
using vvi = std::vector<vi>;
using pii = std::pair<long long int, long long int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
using namespace std;
const long long int N = 2e6 + 10;
const long long int inf = 1e18 + 10;
const long double Pi = 3.14159265;
long long int n;
vi a;
long long int f(vi &a) {
  long long int n = a.size();
  if (a.empty() == 1) return 0;
  if (a.back() == 0) return a.size();
  long long int hig = 0;
  for (long long int i = 0; i <= n - 1; i++) {
    hig = max(hig, (long long int)log2(a[i]));
  }
  vi l, r;
  for (long long int i = 0; i <= n - 1; i++) {
    if ((long long int)log2(a[i]) < hig)
      l.emplace_back(a[i]);
    else
      r.emplace_back(a[i] ^ (1 << (long long int)log2(a[i])));
  }
  if (!(l.size() < r.size())) swap(l, r);
  a = vi();
  if (l.size() == 0) return f(r);
  return 1 + max(f(l), f(r));
}
void solve() {
  cin >> n;
  a.resize(n);
  for (long long int i = 1; i <= n; i++) cin >> a[i - 1];
  sort(a.begin(), a.end());
  cout << (a.size() - f(a));
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
  long long int xx = 0;
  long long int t;
  cin >> t;
  while (t--) {
    ;
    solve();
    cout << endl;
  }
  return 0;
}
