#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 100;
vector<int> adj[N];
int vis[N];
class TrieNode {
 public:
  TrieNode *children[2];
  int cnt, val, idx;
  TrieNode() {
    children[1] = NULL;
    children[0] = NULL;
    cnt = 0;
    val = 0;
    idx = 0;
  }
};
void insert(TrieNode *root, int n, int i) {
  TrieNode *cur = root;
  for (int i = 31; i >= 0; i--) {
    int k = (n & (1 << i)) ? 1 : 0;
    if (cur->children[k] != NULL)
      cur = cur->children[k];
    else
      cur->children[k] = new TrieNode(), cur = cur->children[k];
    cur->cnt += 1;
  }
  cur->val = n;
  cur->idx = i;
}
int func(TrieNode *root, int bits) {
  if (root == NULL) return 0;
  if (root->cnt < 3 or bits < 0) return root->cnt;
  int on = func(root->children[1], bits - 1),
      off = func(root->children[0], bits - 1);
  return max(on, off) + !!min(on, off);
}
int main() {
  TrieNode *root = new TrieNode();
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i], insert(root, a[i], i);
  root->cnt = n;
  cout << n - func(root, 31);
}
