#include <bits/stdc++.h>
using namespace std;
int val[32 * 200005];
int trie[32 * 200005][2];
int a[200005];
int pos = 0;
int add(int num) {
  int c = 0;
  for (int i = 31; i >= 0; i--) {
    int op = ((num >> i) & 1);
    if (!trie[c][op]) trie[c][op] = ++pos;
    c = trie[c][op];
  }
  val[c] = 1;
  return c;
}
int query(int num) {
  int c = 0;
  for (int i = 31; i >= 0; i--) {
    int op = ((num >> i) & 1);
    if (trie[c][op])
      c = trie[c][op];
    else
      c = trie[c][op ^ 1];
  }
  return c;
}
void dfs(int x) {
  if (trie[x][0]) dfs(trie[x][0]);
  if (trie[x][1]) dfs(trie[x][1]);
  if (trie[x][0] != 0 && trie[x][1] != 0)
    val[x] = max(val[trie[x][0]] + min(1, val[trie[x][1]]),
                 val[trie[x][1]] + min(1, val[trie[x][0]]));
  else if (trie[x][0])
    val[x] = max(val[trie[x][0]], val[x]);
  else if (trie[x][1])
    val[x] = max(val[trie[x][1]], val[x]);
}
int n;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &a[i]);
    add(a[i]);
  }
  dfs(0);
  cout << n - val[0] << endl;
  return 0;
}
