#include <bits/stdc++.h>
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
using namespace std;
const long long N = 2e5 + 8;
const long long mod = 998244353;
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int INFi = 0x7f7f7f7f;
const int LEVEL = log2(N) + 1;
const int max_sz = 2;
long long n, a[N], trie[30 * N][max_sz], cnt[30 * N][max_sz];
stack<int> second;
void init() {
  for (int i = 40 * N - 1; i >= 1; i--) second.push(i);
}
void insert(long long x) {
  int v = 0;
  for (int i = 30; i >= 0; i--) {
    int k = (x >> i) & 1;
    if (trie[v][k] == -1) {
      trie[v][k] = second.top();
      second.pop();
    }
    cnt[v][k]++;
    v = trie[v][k];
  }
}
void remove(long long x) {
  int v = 0;
  for (int i = 30; i >= 0; i--) {
    int k = (x >> i) & 1;
    cnt[v][k]--;
    int tmp = trie[v][k];
    if (cnt[v][k] == 0) {
      second.push(tmp);
      trie[v][k] = -1;
    }
    v = tmp;
  }
}
long long dfs(int ind, int x) {
  if (ind == -1) return 1;
  long long res1 = 0, res0 = 0;
  if (trie[x][1] != -1) res1 = dfs(ind - 1, trie[x][1]);
  if (trie[x][0] != -1) res0 = dfs(ind - 1, trie[x][0]);
  return max(res1 + min(1ll, res0), res0 + min(1ll, res1));
}
void solve() {
  init();
  memset(trie, -1, sizeof(trie));
  memset(cnt, 0, sizeof(cnt));
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i], insert(a[i]);
  cout << n - dfs(30, 0) << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed;
  cout << setprecision(15);
  ;
  int test = 1;
  for (int i = 1; i <= test; i++) {
    solve();
  }
}
