#include <bits/stdc++.h>
using namespace std;
inline int read() {
  register int res = 0;
  register char c = getchar(), f = 1;
  while (c < 48 || c > 57) {
    if (c == '-') f = 0;
    c = getchar();
  }
  while (c >= 48 && c <= 57)
    res = (res << 3) + (res << 1) + (c & 15), c = getchar();
  return f ? res : -res;
}
inline void write(int x) {
  register char c[21], len = 0;
  if (!x) return putchar('0'), void();
  if (x < 0) x = -x, putchar('-');
  while (x) c[++len] = x % 10, x /= 10;
  while (len) putchar(c[len--] + 48);
}
const int N = 6e6 + 10;
int n, c[N][2], tot = 1;
void ins(int x) {
  int u = 1, o;
  for (int i = 29; ~i; --i) {
    o = x >> i & 1;
    if (!c[u][o]) c[u][o] = ++tot;
    u = c[u][o];
  }
}
int f[N];
void dfs(int u) {
  if (!u) return;
  dfs(c[u][0]), dfs(c[u][1]);
  if (c[u][0] && c[u][1])
    f[u] = max(f[c[u][0]], f[c[u][1]]) + 1;
  else if (!c[u][0] && !c[u][1])
    f[u] = 1;
  else
    f[u] = f[c[u][0]] | f[c[u][1]];
}
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) ins(read());
  dfs(1), write(n - f[1]), putchar('\n');
}
