#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 77, LOG = 32;
int T, n, a[N], tim = 1;
int dp[N * LOG], is[N * LOG], le[N * LOG], ri[N * LOG];
inline void Add(int x) {
  int cur = 1;
  is[cur] = 1;
  for (int i = 29; i >= 0; --i) {
    if ((x >> i) & 1) {
      if (ri[cur] == 0) ri[cur] = ++tim;
      cur = ri[cur];
    } else {
      if (le[cur] == 0) le[cur] = ++tim;
      cur = le[cur];
    }
    is[cur] = 1;
  }
}
void Solve(int v) {
  if (v == 0) return;
  dp[v] = is[v];
  Solve(le[v]);
  Solve(ri[v]);
  dp[v] = max(max(dp[le[v]] + is[ri[v]], dp[ri[v]] + is[le[v]]), dp[v]);
}
inline void Test() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", a + i), Add(a[i]);
  Solve(1);
  printf("%d\n", n - dp[1]);
}
int main() {
  T = 1;
  while (T--) Test();
  return 0;
}
