#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const double PI = acos(-1.0);
const double epsilon = PI / 180.0;
const double eps = 1e-6;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res % mod;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
const int N = 2e5 + 10, M = 1e6 + 10;
int n;
int a[N];
int f[N * 30];
int son[N * 30][2], idx;
int tag[N * 30];
void insert(int x) {
  int p = 0;
  for (int i = 31 - 1; i >= 0; i--) {
    int u = x >> i & 1;
    if (!son[p][u]) son[p][u] = ++idx;
    p = son[p][u];
  }
  tag[p]++;
}
void dfs(int u) {
  for (int i = 0; i < 2; i++)
    if (son[u][i]) dfs(son[u][i]);
  f[u] = max(f[son[u][0]] + (son[u][1] > 0), f[son[u][1]] + (son[u][0] > 0));
  if (!f[u]) f[u] = max(tag[u], 1);
}
int main() {
  cin >> n;
  for (int i = 1; i < n + 1; i++) cin >> a[i];
  for (int i = 1; i < n + 1; i++) insert(a[i]);
  dfs(0);
  cout << n - f[0];
  return 0;
}
