#include <bits/stdc++.h>
using namespace std;
const long long N = 200010;
long long n, cnt = 1, tree[N * 20][2], root = 1;
inline long long read() {
  long long x = 0, tmp = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') tmp = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  return tmp * x;
}
inline void Insert(long long val) {
  long long p = root;
  for (long long i = 30; i >= 0; i--) {
    long long x = (val >> i) & 1;
    if (!tree[p][x]) tree[p][x] = ++cnt;
    p = tree[p][x];
  }
}
long long query(long long p) {
  if (!tree[p][0] && !tree[p][1]) return 1;
  if (!tree[p][0]) return query(tree[p][1]);
  if (!tree[p][1]) return query(tree[p][0]);
  return max(query(tree[p][0]), query(tree[p][1])) + 1;
}
int main() {
  n = read();
  for (long long i = 1; i <= n; i++) Insert(read());
  cout << n - query(root) << endl;
  return 0;
}
