#include <bits/stdc++.h>
using namespace std;
template <class T>
void print(T &x) {
  cout << x;
}
template <class T, class U>
void print(pair<T, U> &p) {
  cout << "(";
  print(p.first);
  cout << ", ";
  print(p.second);
  cout << ")";
}
template <class T>
void print(vector<T> &v) {
  cout << "{";
  if (((int)(v).size())) print(v[0]);
  for (int i = 1; i < ((int)(v).size()); i++) cout << ", ", print(v[i]);
  cout << "}\n";
}
const int n = 5e5 + 5;
int N, M, K, T;
vector<long long> A;
int cnt(vector<long long> A, int b) {
  if (((int)(A).size()) == 1) return 1;
  if (((int)(A).size()) == 0) return 0;
  vector<long long> B;
  while (!A.empty() && A[((int)(A).size()) - 1] >= 1LL << b) {
    long long v = A[((int)(A).size()) - 1];
    A.pop_back();
    B.push_back(v ^ (1LL << b));
  }
  int szA = ((int)(A).size());
  int t1 = cnt(A, b - 1) + (((int)(B).size()) > 0 ? 1 : 0);
  sort(B.begin(), B.end());
  int t2 = cnt(B, b - 1) + (szA > 0 ? 1 : 0);
  return max(t1, t2);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  A.resize(N);
  for (long long &a : A) cin >> a;
  sort(A.begin(), A.end());
  int c = cnt(A, 31);
  cout << N - c << endl;
  return 0;
}
