#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int n, a[maxn];
int dfs(int l, int r, int x) {
  if (!x) return 1;
  int id = l;
  while (id <= r) {
    if (a[id] & x) break;
    ++id;
  }
  if (id == r + 1 || id == l) return dfs(l, r, (x >> 1));
  return 1 + max(dfs(l, id - 1, x >> 1), dfs(id, r, x >> 1));
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  sort(a + 1, a + 1 + n);
  printf("%d\n", n - dfs(1, n, 1 << 29));
}
