#include <bits/stdc++.h>
using namespace std;
vector<int> R;
int DFS(vector<int> a, int dep) {
  if (a.size() <= 2) return a.size();
  int i, x, y, ans;
  vector<int> b, c;
  for (i = 0; i < a.size(); i++) {
    if ((1 << dep) & a[i])
      b.push_back(a[i]);
    else
      c.push_back(a[i]);
  }
  x = DFS(b, dep - 1), y = DFS(c, dep - 1), ans = max(x, y);
  if (min(x, y)) ans++;
  return ans;
}
int main() {
  int i, x, n;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &x), R.push_back(x);
  printf("%d\n", n - DFS(R, 30));
  return 0;
}
