#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, maxn = 4e6 + 10, M = 5010;
const long long mod = 998244353;
int n, m;
struct Tire {
  int tree[maxn][2], tot = 1;
  void Insert(int x) {
    int p = 1;
    for (int i = 0; i <= 31; ++i) {
      int op = x >> (31 - i) & 1;
      if (!tree[p][op]) tree[p][op] = ++tot;
      p = tree[p][op];
    }
  }
  int dfs(int u) {
    if (u == 0) return 0;
    if (tree[u][0] == 0 && tree[u][1] == 0) return 1;
    return max(dfs(tree[u][0]) + (tree[u][1] > 0),
               dfs(tree[u][1]) + (tree[u][0] > 0));
  }
} T;
void sol() {
  scanf("%d", &n);
  for (int i = 1, x; i <= n; ++i) {
    scanf("%d", &x);
    T.Insert(x);
  }
  printf("%d\n", n - T.dfs(1));
}
int main() {
  sol();
  return 0;
}
