#include <bits/stdc++.h>
using namespace std;
const long long mxN = 2e5;
long long n, a[39 * mxN + 1], ch[mxN * 30][2], ct[mxN * 30], nodes = 1, ans = 0;
void insert(long long k) {
  long long u = 0;
  for (long long i = 30; ~i; --i) {
    long long bit = ((k >> i) & 1);
    if (!ch[u][bit]) ch[u][bit] = nodes++;
    u = ch[u][bit];
  }
  ++ct[u];
}
void dfs(long long u = 0) {
  for (long long i = 0; i < 2; i++) {
    if (ch[u][i]) dfs(ch[u][i]), ct[u] += ct[ch[u][i]];
  }
}
long long dfs1(long long u = 0) {
  if (ct[u]) return ct[u];
  vector<long long> v;
  for (long long i = 0; i < 2; i++) {
    if (ch[u][i])
      v.push_back(dfs1(ch[u][i]));
    else
      v.push_back(0);
  }
  return max(v[0] + min(1LL, v[1]), v[1] + min(1LL, v[0]));
}
signed main() {
  cin >> n;
  vector<long long> a(n);
  for (long long &x : a) {
    cin >> x;
    insert(x);
  }
  cout << n - dfs1();
}
