#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline long long rand(long long x, long long y) {
  return rng() % (y + 1 - x) + x;
}
string inline to_string(char c) {
  string second(1, c);
  return second;
}
template <typename T>
inline T gcd(T a, T b) {
  return a == 0 ? llabs(b) : gcd(b % a, a);
}
using ll = long long;
using ld = long double;
using pi = pair<ll, ll>;
using spi = pair<ll, pi>;
using dpi = pair<pi, pi>;
int n, l[(10000006)], r[(10000006)], sz[(10000006)], co;
void insert(ll id, int bit, ll x) {
  if (bit == -1) {
    sz[id] = 1;
    return;
  }
  if (1 << bit & x) {
    if (r[id] == -1) r[id] = ++co;
    insert(r[id], bit - 1, x);
  } else {
    if (l[id] == -1) l[id] = ++co;
    insert(l[id], bit - 1, x);
  }
}
ll dp(ll x) {
  if (sz[x]) return 1;
  if (r[x] == -1) return dp(l[x]);
  if (l[x] == -1) return dp(r[x]);
  return max(dp(l[x]), dp(r[x])) + 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  memset((l), -1, sizeof((l))), memset((r), -1, sizeof((r)));
  for (ll i = 1; i <= ll(n); ++i) {
    ll a;
    cin >> a;
    insert(0, 29, a);
  }
  cout << n - dp(0) << '\n';
}
