#include <bits/stdc++.h>
using namespace std;
int arr[200005];
int go(vector<int> &v) {
  int i, j, k, a, b, c, n, l, r, ret;
  n = v.size();
  if (n <= 1) return n;
  sort(v.begin(), v.end());
  c = 0;
  l = n - 1;
  ret = 0;
  for (i = 29; i >= 0; i--) {
    a = (1 << i);
    if (l < 0) break;
    if (v[l] & a) {
      for (j = l; j >= 0; j--) {
        if ((v[j] & a) == 0) break;
        r = j;
      }
      vector<int> vec;
      vec.clear();
      for (j = l; j >= r; j--) vec.push_back(v[j] - a);
      k = go(vec);
      b = 0;
      if (r) b = 1;
      ret = max(ret, k + c + b);
      c++;
      l = r - 1;
    }
  }
  return ret;
}
void solve() {
  int i, j, k, a, b, c, n;
  scanf("%d", &n);
  vector<int> vec;
  for (i = 1; i <= n; i++) {
    scanf("%d", &arr[i]);
    vec.push_back(arr[i]);
  }
  printf("%d\n", n - go(vec));
}
int main() {
  int T = 1;
  while (T--) {
    solve();
  }
}
