#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 0;
  char ch = getchar();
  while (!isdigit(ch)) f |= ch == '-', ch = getchar();
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ '0'), ch = getchar();
  return f ? -x : x;
}
inline void write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + 48);
}
inline void writebl(long long x) {
  write(x);
  putchar(' ');
}
inline void writeln(long long x) {
  write(x);
  putchar('\n');
}
const long long N = 4e6 + 5;
long long ch[N][3], cnt = 1, val[N];
void ins(long long x) {
  long long u = 1;
  for (long long i = (30); i >= (0); --i) {
    long long v = (x >> i) & 1;
    if (!ch[u][v]) ch[u][v] = ++cnt;
    u = ch[u][v];
  }
}
long long n, a[N];
long long dfs(long long u) {
  long long r1 = 0, r2 = 0;
  if (!ch[u][0] && !ch[u][1]) return 1;
  if (!ch[u][0]) return dfs(ch[u][1]);
  if (!ch[u][1]) return dfs(ch[u][0]);
  return max(dfs(ch[u][0]), dfs(ch[u][1])) + 1;
}
signed main() {
  n = read();
  for (long long i = (1); i <= (n); ++i) a[i] = read(), ins(a[i]);
  writeln(n - dfs(1));
}
