#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const int M = 1e7 + 5;
const int inf = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
const double eps = 1e-8;
const long double pi = acos(-1.0L);
long long read() {
  long long x = 0, t = 1;
  char ch;
  while (!isdigit(ch = getchar()))
    if (ch == '-') t = -1;
  while (isdigit(ch)) {
    x = 10 * x + ch - '0';
    ch = getchar();
  }
  return x * t;
}
int bt[N << 5][2], a[N], cnt = 1;
void ins(int x) {
  int p = 1;
  for (int i = 29; i >= 0; i--) {
    int t = ((1 << i) & x) > 0;
    if (!bt[p][t]) bt[p][t] = ++cnt;
    p = bt[p][t];
  }
}
int dfs(int u) {
  if (!bt[u][0] && !bt[u][1]) return 1;
  int t0 = 0, t1 = 0;
  if (bt[u][0]) t0 = dfs(bt[u][0]);
  if (bt[u][1]) t1 = dfs(bt[u][1]);
  if (t0 && t1)
    return max(t0, t1) + 1;
  else
    return t1 + t0;
}
int main() {
  int n = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  for (int i = 1; i <= n; i++) ins(a[i]);
  printf("%d\n", n - dfs(1));
  return 0;
}
