#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template <typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) { return (ull)rng() % B; }
clock_t startTime;
double getCurrentTime() {
  return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}
const int S = (int)7e6;
const int K = 30;
int g[S][2];
int n, m = 1;
int ans = 1;
void dfs(int v, int x) {
  if (g[v][0] == 0 && g[v][1] == 0) {
    ans = max(ans, x);
    return;
  }
  if (g[v][0] != 0 && g[v][1] != 0) x++;
  for (int c = 0; c < 2; c++) {
    if (g[v][c] != 0) dfs(g[v][c], x);
  }
}
int main() {
  startTime = clock();
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    int v = 0;
    for (int k = K - 1; k >= 0; k--) {
      int c = (x >> k) & 1;
      if (g[v][c] == 0) g[v][c] = m++;
      v = g[v][c];
    }
  }
  dfs(0, 1);
  printf("%d\n", n - ans);
  return 0;
}
