#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 500;
int n;
long long a[maxn], ans;
long long dfs(int l, int r, int now) {
  if (l == r) {
    return 1;
  }
  long long fenge = r + 1;
  for (int i = l; i <= r; i++) {
    if (a[i] & (1 << now)) {
      fenge = i;
      break;
    }
  }
  long long ans = 0;
  if (fenge == l || fenge == r + 1) {
    ans = dfs(l, r, now - 1);
  } else {
    ans = max(dfs(l, fenge - 1, now - 1), dfs(fenge, r, now - 1)) + 1;
  }
  return ans;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + n + 1);
  ans = dfs(1, n, 30);
  cout << n - ans << endl;
  return 0;
}
