#include <bits/stdc++.h>
using namespace std;
const long long maxn = 2e5 + 100;
long long read() {
  long long ans = 0;
  bool f = 0;
  char ch = getchar();
  while (ch < '0' or ch > '9') {
    if (ch == '-') f = 1;
    ch = getchar();
  };
  while (ch >= '0' and ch <= '9') {
    ans = (ans << 1) + (ans << 3) + (ch ^ 48);
    ch = getchar();
  }
  return f ? ~ans + 1 : ans;
}
int n, m, a[maxn], wei[40], pos, ans, flag, flagcnt, tr[maxn * 31][2], cnt,
    dp[maxn * 31];
void cr(int x) {
  int now = 1;
  for (int i = 31; i >= 0; --i) {
    int gg = (x >> i) & 1;
    if (tr[now][gg])
      now = tr[now][gg];
    else
      tr[now][gg] = ++cnt, now = cnt;
  }
}
void dfs(int now) {
  int hh = 0;
  for (int i = 0; i <= 1; ++i) {
    if (tr[now][i]) {
      dfs(tr[now][i]);
      hh++;
      dp[now] = max(dp[now], dp[tr[now][i]]);
    }
  }
  if (hh != 1) dp[now]++;
}
int main() {
  n = read();
  cnt = 1;
  for (int i = 1; i <= n; ++i) {
    a[i] = read();
    cr(a[i]);
  }
  dfs(1);
  cout << n - dp[1];
  return 0;
}
