#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 100;
const long long MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long LLINF = 0x3f3f3f3f3f3f3f3f;
const long double EPS = 1e-7;
const long double PI = acos(-1);
int solve(int b, vector<int> &vals) {
  if (b < 0) return vals.size();
  vector<int> zero, um;
  for (auto v : vals) {
    if (v & (1 << b))
      um.push_back(v);
    else
      zero.push_back(v);
  }
  if (um.empty()) return solve(b - 1, zero);
  if (zero.empty()) return solve(b - 1, um);
  if (um.size() == 1) return 1 + solve(b - 1, zero);
  if (zero.size() == 1) return 1 + solve(b - 1, um);
  return 1 + max(solve(b - 1, zero), solve(b - 1, um));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  cout << n - solve(31, a) << '\n';
  return 0;
}
