#include <bits/stdc++.h>
using namespace std;
long long in() {
  long long a;
  scanf("%lld", &a);
  return a;
}
double din() {
  double a;
  scanf("%lf", &a);
  return a;
}
long long bigmod(long long b, long long p, long long md) {
  if (p == 0) return 1;
  if (p % 2 == 1) {
    return ((b % md) * bigmod(b, p - 1, md)) % md;
  } else {
    long long y = bigmod(b, p / 2, md);
    return (y * y) % md;
  }
}
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long getRandom(long long a, long long b) {
  long long ret = (long long)rand() * (long long)rand();
  ret %= (b - a + 1);
  ret += a;
  return ret;
}
int solve(vector<int> v) {
  if (v.size() == 1) return 1;
  int mx = 0, bla = 0;
  vector<int> vv;
  for (int i = 0; i < v.size(); i++) {
    if (i == v.size() - 1 || (v[i] ^ v[i + 1]) > v[i]) {
      for (int j = 32; j >= 0; j--) {
        if (v[i] & (1LL << j)) {
          v[i] ^= (1LL << j);
          break;
        }
      }
      vv.push_back(v[i]);
      mx = max(mx + 1, bla + solve(vv));
      bla = 1;
      vv.clear();
    } else {
      for (int j = 32; j >= 0; j--) {
        if (v[i] & (1LL << j)) {
          v[i] ^= (1LL << j);
          break;
        }
      }
      vv.push_back(v[i]);
    }
  }
  return mx;
}
int main() {
  int n = in();
  vector<int> v;
  for (int i = 0; i < n; i++) v.push_back(in());
  sort(v.begin(), v.end());
  int mx = solve(v);
  printf("%lld\n", (long long)n - mx);
}
