#include <bits/stdc++.h>
struct Node {
  Node *nodes[2];
  int cnt;
  Node(int cnt = 1) : cnt(cnt) { nodes[0] = nodes[1] = NULL; }
};
struct Trie {
  Node *root;
  Trie() : root(new Node(0)) {}
  void insert(int x) {
    Node *p = root;
    int i = 30;
    while (p) {
      int d = (x & (1 << i)) ? 1 : 0;
      ++(p->cnt);
      if (p->nodes[d])
        p = p->nodes[d];
      else
        break;
      --i;
    }
    while (~i) p = p->nodes[(x & (1 << i--)) ? 1 : 0] = new Node();
  }
  int getCnt(Node *p) { return p == NULL ? 0 : p->cnt; }
  int solve() { return solve(root); }
  int solve(Node *p) {
    if (!p) return 0;
    int lc = getCnt(p->nodes[0]), rc = getCnt(p->nodes[1]);
    int ls = solve(p->nodes[0]), rs = solve(p->nodes[1]);
    int l = ls + (rc > 0 ? rc - 1 : 0), r = rs + (lc > 0 ? lc - 1 : 0);
    return l > r ? r : l;
  }
};
int main() {
  int n, x;
  scanf("%d", &n);
  Trie trie;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &x);
    trie.insert(x);
  }
  printf("%d\n", trie.solve());
  return 0;
}
