#include <bits/stdc++.h>
using namespace std;
const long long Mod = 1e9 + 7;
long long poww(long long a, long long b, long long mod) {
  long long res = 1;
  if (b < 0) b = (b % (mod - 1) + mod - 1) % (mod - 1);
  for (; b; b >>= 1, a = 1ll * a * a % mod)
    if (b & 1) res = 1ll * res * a % mod;
  return res;
}
void Max(long long& x, long long y) { x = max(x, y); }
void Min(long long& x, long long y) { x = min(x, y); }
void OK(bool yes) { cout << (yes ? "yes\n" : "no\n"); }
const long long N = 2000200, M = 1010, LN = (1 << 24), K = 17, Mx = 3e5,
                inf = 1e15;
const long double pi = acos(-1), eps = 1e-6;
long long solve(vector<long long>& v) {
  if (v.empty()) return 0;
  long long c = 0;
  vector<long long> v0, v1;
  long long mx = 0;
  for (int i = 0; i < v.size(); i++) {
    Max(mx, v[i]);
    c += (v[i] == v[0]);
  }
  if (c == v.size()) return v.size();
  long long msb = 0;
  while (mx > 1) {
    mx >>= 1;
    msb++;
  }
  for (int i = 0; i < v.size(); i++) {
    if (v[i] & (1 << msb))
      v1.push_back(v[i] ^ (1 << msb));
    else
      v0.push_back(v[i]);
  }
  if (v1.empty() || v0.empty()) return max(solve(v1), solve(v0));
  return max(solve(v1), solve(v0)) + 1;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int T = 1;
  while (T--) {
    long long n;
    cin >> n;
    vector<long long> v;
    for (int i = 1; i <= n; i++) {
      long long x;
      cin >> x;
      v.push_back(x);
    }
    cout << n - solve(v);
  }
  return 0;
}
