#include <bits/stdc++.h>
using namespace std;
struct vl {
  long long x, y;
  bool operator<(const vl& t) const {
    if (x == t.x) return y < t.y;
    return x < t.x;
  }
};
const long long INF = 1e18;
const long long mod = 1e9 + 7;
const long long MAXN = 1e6 + 69;
long long q = 1, m, n, x, y, z, k, l;
struct Trie {
  Trie* child[2];
  long long cnt;
  Trie() {
    for (long long i = 0; i < 2; ++i) child[i] = nullptr;
    cnt = 0;
  }
};
long long val[MAXN];
long long ans;
long long getbit(long long n, long long i) { return (n >> i) & 1; }
inline void maximize(long long& a, long long b) { a = (a > b) ? a : b; }
void dfs(Trie* t, long long dep = 0) {
  if (t->child[0] && t->child[1]) {
    dep += 1;
  }
  maximize(ans, dep);
  if (t->child[0]) dfs(t->child[0], dep);
  if (t->child[1]) dfs(t->child[1], dep);
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  if (fopen(""
            ".INP",
            "r")) {
    freopen(
        ""
        ".INP",
        "r", stdin);
    freopen(
        ""
        ".OUT",
        "w", stdout);
  }
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> val[i];
  Trie* root = new Trie();
  for (long long i = 1; i <= n; i++) {
    Trie* tmp = root;
    root->cnt++;
    for (long long j = 29; j >= 0; j--) {
      if (getbit(val[i], j)) {
        if (tmp->child[1] == NULL) tmp->child[1] = new Trie();
        tmp = tmp->child[1];
        tmp->cnt++;
      } else {
        if (tmp->child[0] == NULL) tmp->child[0] = new Trie();
        tmp = tmp->child[0];
        tmp->cnt++;
      }
    }
  }
  dfs(root);
  cout << n - ans - 1;
}
