#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 2;
int tree[N * 32][2], cnt[N * 32];
long long int curr = 1, n, ans;
vector<long long int> arr(N);
void clean() {
  for (long long int i = 0; i <= N * 32 - 1; i++) tree[i][0] = tree[i][1] = -1;
}
void add(long long int x) {
  long long int v = 0;
  cnt[v]++;
  for (long long int i = 32; i >= 0; i--) {
    long long int b = (x >> i) & 1;
    if (tree[v][b] == -1) tree[v][b] = curr++;
    v = tree[v][b];
    cnt[v]++;
  }
}
long long int calc(int v) {
  if (v == -1) return 0;
  int s0 = 0, s1 = 0;
  if (tree[v][0] != -1) s0 = cnt[tree[v][0]];
  if (tree[v][1] != -1) s1 = cnt[tree[v][1]];
  if (s0 == 0 && s1 == 0) return cnt[v];
  if (s0 == 0) return calc(tree[v][1]);
  if (s1 == 0) return calc(tree[v][0]);
  return 1 + max(calc(tree[v][0]), calc(tree[v][1]));
}
int main() {
  clean();
  cin >> n;
  for (long long int i = 0; i <= n - 1; i++) cin >> arr[i], add(arr[i]);
  cout << n - calc(0);
}
