#include <bits/stdc++.h>
#pragma GCC optimize(3)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target("avx2,fma")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
const int N = 400010, M = 33;
inline int read() {
  int s = 0, w = 1;
  register char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    s = (s << 3) + (s << 1) + (ch ^ 48), ch = getchar();
  return s * w;
}
int n, a[N];
int ch[N * M][2], tot = 1;
inline void Insert(int x) {
  int k = 1;
  for (register int i = 30; ~i; i--) {
    int p = (x >> i) & 1;
    if (!ch[k][p]) ch[k][p] = ++tot;
    k = ch[k][p];
  }
}
int DFS(int x) {
  if (!ch[x][0] && !ch[x][1]) return 1;
  if (!ch[x][0]) return DFS(ch[x][1]);
  if (!ch[x][1]) return DFS(ch[x][0]);
  return max(DFS(ch[x][0]), DFS(ch[x][1])) + 1;
}
signed main() {
  n = read();
  for (register int i = 1; i <= n; i++) a[i] = read(), Insert(a[i]);
  printf("%d\n", n - DFS(1));
  return 0;
}
