#include <bits/stdc++.h>
using namespace std;
int n, x;
struct node {
  int nxt[2];
  node() { memset(nxt, -1, sizeof(nxt)); }
};
vector<node> trie = {node()};
int ans = 0;
void add(int x) {
  int v = 0;
  for (int i = 30; i >= 0; i--) {
    int b = (x >> i) & 1;
    if (trie[v].nxt[b] == -1) {
      trie[v].nxt[b] = trie.size();
      trie.push_back(node());
    }
    v = trie[v].nxt[b];
  }
}
void solve(int v, int act) {
  if (trie[v].nxt[0] != -1 && trie[v].nxt[1] != -1) {
    act++;
  }
  ans = max(ans, act);
  if (trie[v].nxt[0] != -1) {
    solve(trie[v].nxt[0], act);
  }
  if (trie[v].nxt[1] != -1) {
    solve(trie[v].nxt[1], act);
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> x;
    add(x);
  }
  solve(0, 0);
  cout << n - (ans + 1) << "\n";
  return 0;
}
