#include <bits/stdc++.h>
using namespace std;
const int maxn = 4000004;
int ch[maxn][2];
int tot, n, a[maxn];
int dp[maxn];
void jia(int x) {
  int nw = 0;
  for (int i = 30; i >= 0; --i) {
    int c = ch[nw][(x >> i) & 1];
    if (!c) ch[nw][(x >> i) & 1] = ++tot;
    nw = ch[nw][(x >> i) & 1];
  }
  dp[nw]++;
}
void dfs(int x) {
  for (int i = 0; i < 2; ++i) {
    if (ch[x][i]) dfs(ch[x][i]);
    dp[x] = max(dp[x], dp[ch[x][i]]);
  }
  if (ch[x][1] != 0 && ch[x][0] != 0) dp[x]++;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]), jia(a[i]);
  dfs(0);
  printf("%d\n", n - dp[0]);
}
