#include <bits/stdc++.h>
using namespace std;
const int M = 2e5 + 10;
const int inf = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
const int bit = 32;
const double pi = acos(-1.0);
int a[M];
int dfs(int k, int l, int r) {
  if (l > r) return 0;
  if (k < 0) return 1;
  int mid = r;
  int t = 1 << k;
  for (int i = l; i <= r; i++) {
    if (t & a[i]) {
      mid = i - 1;
      break;
    }
  }
  int x = dfs(k - 1, l, mid), y = dfs(k - 1, mid + 1, r);
  return max(x + min(r - mid, 1), y + min(mid - l + 1, 1));
}
int main() {
  int n;
  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(30, 1, n));
  return 0;
}
