#include <bits/stdc++.h>
using namespace std;
const int MAXN = 10000005;
const int SQRTN = 1003;
const int LOGN = 22;
const double PI = acos(-1);
const int INF = 1e9;
const int MOD = 1000000007;
const int FMOD = 998244353;
const double eps = 1e-9;
void solvethetestcase();
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  for (int testcase = 1; testcase < t + 1; testcase++) {
    solvethetestcase();
  }
}
int n;
int trie[MAXN][2];
int sub[MAXN], cnt[MAXN];
int dp[MAXN];
int SZ = 1;
void insert(int node, int bt, int num) {
  sub[node]++;
  if (bt == -1) {
    cnt[node] = 1;
    return;
  }
  if ((1 << bt) & num) {
    if (trie[node][1] == -1) trie[node][1] = SZ++;
    insert(trie[node][1], bt - 1, num);
  } else {
    if (trie[node][0] == -1) trie[node][0] = SZ++;
    insert(trie[node][0], bt - 1, num);
  }
}
void dfs(int node) {
  if (cnt[node] == 1) {
    dp[node] = 1;
    return;
  }
  if (trie[node][0] == -1) {
    dfs(trie[node][1]);
    dp[node] = dp[trie[node][1]];
  } else if (trie[node][1] == -1) {
    dfs(trie[node][0]);
    dp[node] = dp[trie[node][0]];
  } else {
    dfs(trie[node][0]);
    dfs(trie[node][1]);
    dp[node] = max(dp[trie[node][0]] + 1, dp[trie[node][1]] + 1);
  }
}
void solvethetestcase() {
  cin >> n;
  for (int i = 0; i < MAXN; i++) {
    trie[i][0] = -1;
    trie[i][1] = -1;
    cnt[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    insert(0, 30, x);
  }
  dfs(0);
  cout << n - dp[0] << endl;
}
