#include <bits/stdc++.h>
using namespace std;
template <class C>
struct rge {
  C b, e;
};
template <class C>
rge<C> range(C x, C y) {
  return rge<C>{x, y};
}
template <class C>
auto dud(C *x) -> decltype(cerr << *x, 0);
template <class C>
char dud(...);
struct debug {
  ~debug() { cerr << "\n"; }
  template <class C>
  typename enable_if<sizeof dud<C>(0) != 1, debug &>::type operator<<(C i) {
    cerr << boolalpha << i;
    return *this;
  }
  template <class C>
  typename enable_if<sizeof dud<C>(0) == 1, debug &>::type operator<<(C i) {
    return *this << range(begin(i), end(i));
  }
  template <class C1, class C2>
  debug &operator<<(pair<C1, C2> p) {
    return *this << "(" << p.first << ", " << p.second << ")";
  }
  template <class C>
  debug &operator<<(rge<C> r) {
    *this << "[";
    for (auto it = r.b; it != r.e; ++it) *this << ", " + 2 * (it == r.b) << *it;
    return *this << "]";
  }
};
const int nax = 2e5 + 5;
int child[30 * nax][2];
int cnt[30 * nax];
int nxt;
int dfs(int node) {
  if (cnt[node]) {
    return cnt[node];
  }
  vector<int> v;
  for (int me : {0, 1}) {
    if (child[node][me]) {
      v.push_back(dfs(child[node][me]));
    } else {
      v.push_back(0);
    }
  }
  return max(v[0] + min(1, v[1]), v[1] + min(1, v[0]));
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    int node = 0;
    for (int bit = 29; bit >= 0; --bit) {
      bool me = x & (1 << bit);
      if (!child[node][me]) {
        child[node][me] = ++nxt;
      }
      node = child[node][me];
    }
    cnt[node]++;
  }
  cout << n - dfs(0);
  return 0;
}
