#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int a[N], n;
int cal(int l, int r, int d) {
  if (l > r) return 0;
  if (d == -1) return 1;
  int mid = l;
  while (mid <= r && ((a[mid] >> d) & 1) == 0) mid++;
  int res = 0;
  if (mid <= r)
    res = max(res, cal(l, mid - 1, d - 1) + 1);
  else
    res = max(res, cal(l, mid - 1, d - 1));
  if (mid > l)
    res = max(res, cal(mid, r, d - 1) + 1);
  else
    res = max(res, cal(mid, r, d - 1));
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  cout << n - cal(1, n, 29);
  return 0;
}
