#include <bits/stdc++.h>
using namespace std;
const int N = 6e6 + 7;
int f[N][2], g[N];
int tot = 0;
void build(int x) {
  int now = 0;
  for (int i = 30; i >= 0; i--) {
    int t = x >> i & 1;
    if (f[now][t] == -1) {
      f[now][t] = ++tot;
    }
    g[now] += 1;
    now = f[now][t];
  }
  g[now] += 1;
}
int gao(int x) {
  if (f[x][0] == -1 && f[x][1] == -1) return g[x];
  if (f[x][0] == -1) return gao(f[x][1]);
  if (f[x][1] == -1) return gao(f[x][0]);
  int t1 = gao(f[x][0]), t2 = gao(f[x][1]);
  if (t1 < t2) return t2 + min(t1, 1);
  return t1 + min(t2, 1);
}
int main() {
  int n;
  scanf("%d", &n);
  memset(f, -1, sizeof(f));
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    build(x);
  }
  int ans = n - gao(0);
  printf("%d", ans);
  return 0;
}
