#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long x = 0, f = 0;
  char c = getchar();
  while (!isdigit(c)) f |= c == '-', c = getchar();
  while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
  return f ? -x : x;
}
inline int max(int a, int b, int c) { return max(a, max(b, c)); }
int n, m, a[200010];
struct Trie {
  int nxt[2], sz;
} T[200010 * 31];
int rt = 1, top = 1;
void insert(int x) {
  int now = rt;
  for (int i = 31; ~i; --i) {
    if (!T[now].nxt[x >> i & 1]) T[now].nxt[x >> i & 1] = ++top;
    now = T[now].nxt[x >> i & 1];
  }
  T[now].sz = 1;
}
int ans;
int dfs(int i, int d) {
  if (!i) return 0;
  int ls, rs;
  if (d == -1) return min(2, T[i].sz);
  ls = dfs(T[i].nxt[0], d - 1);
  T[i].sz += T[T[i].nxt[0]].sz;
  rs = dfs(T[i].nxt[1], d - 1);
  T[i].sz += T[T[i].nxt[1]].sz;
  if (ls == 2 && rs == 2)
    ans += min(T[T[i].nxt[0]].sz, T[T[i].nxt[1]].sz) - 1,
        T[i].sz -= min(T[T[i].nxt[0]].sz, T[T[i].nxt[1]].sz) - 1;
  return min(2, ls + rs);
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) a[i] = read(), insert(a[i]);
  dfs(rt, 31);
  cout << ans << endl;
  return 0;
}
