#include <bits/stdc++.h>
using namespace std;
struct Node {
  int sz, val;
  Node *left, *right;
  Node() : left(NULL), right(NULL), sz(0), val(-1) {}
  ~Node() {
    delete left;
    delete right;
  }
};
int A[200000];
void insert(Node*& curr, int i, int x) {
  if (curr == NULL) curr = new Node();
  if (i == -1)
    curr->val = x;
  else {
    if ((1 << i) & A[x])
      insert(curr->left, i - 1, x);
    else
      insert(curr->right, i - 1, x);
  }
  curr->sz += 1;
  return;
}
int find(Node* curr) {
  if (curr == NULL) return 0;
  if (curr->val > -1) return 1;
  if (curr->left == NULL) return find(curr->right);
  if (curr->left->sz == 1) return 1 + find(curr->right);
  if (curr->right == NULL) return find(curr->left);
  if (curr->right->sz == 1) return 1 + find(curr->left);
  return 1 + max(find(curr->left), find(curr->right));
}
int main() {
  int n;
  cin >> n;
  Node* root = NULL;
  for (int i = 0; i < n; ++i) {
    cin >> A[i];
    insert(root, 31, i);
  }
  cout << n - find(root);
  delete root;
  return 0;
}
