#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vii = vector<pii>;
int n, a[200000];
int solve(int s, int e, int d) {
  if (s == e || d == 0) return e - s + 1;
  int m = s;
  while (m <= e && a[m] % (1 << d) < (1 << (d - 1))) m++;
  int lv = m - 1 >= s ? solve(s, m - 1, d - 1) : 0;
  int rv = m <= e ? solve(m, e, d - 1) : 0;
  return max(lv + min(rv, 1), rv + min(lv, 1));
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", a + i);
  sort(a, a + n);
  int ans = n - solve(0, n - 1, 30);
  printf("%d", ans);
}
