#include <bits/stdc++.h>
using namespace std;
vector<int> A;
int F(int q, int w, int pr) {
  if (w - q <= 2) return w - q;
  int s = q;
  int g = 0;
  int ans = 2;
  while (s < w) {
    int f = s;
    int st = 1;
    while (st <= (A[s] - pr)) st <<= 1;
    st = pr + (st >> 1);
    while (f < w && (A[f] & st) == st) f++;
    ans = max(ans, F(s, f, st) + g + ((f == w) ? 0 : 1));
    s = f;
    g++;
  }
  return ans;
}
int main() {
  int n;
  scanf("%d", &n);
  A.resize(n);
  for (int i = 0; i < n; i++) scanf("%d", &A[i]);
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  printf("%d\n", n - F(0, n, 0));
  return 0;
}
