#include <bits/stdc++.h>
using namespace std;
const int maxl = 2e5 + 10;
int n, m, cnt, tot, cas, ans;
int a[maxl], b[maxl], num[maxl * 32];
int ind[maxl * 32], sz[maxl * 32], tr[maxl * 32][2];
bool vis[maxl], pr[maxl];
char s[maxl];
vector<int> e[maxl];
inline void prework() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    int u = 0, c;
    for (int j = 30; j >= 0; j--) {
      c = (a[i] >> j) & 1;
      if (!tr[u][c]) tr[u][c] = ++tot;
      u = tr[u][c];
      ++num[u];
    }
    ind[u] = i;
  }
}
inline int dfs(int u) {
  if (!tr[u][0] && !tr[u][1]) return 1;
  int l = 0, r = 0;
  if (tr[u][0]) l = dfs(tr[u][0]);
  if (tr[u][1]) r = dfs(tr[u][1]);
  if (!tr[u][1]) return l;
  if (!tr[u][0]) return r;
  return max(l, r) + 1;
}
inline void mainwork() { ans = n - dfs(0); }
inline void print() { printf("%d\n", ans); }
int main() {
  int t = 1;
  for (cas = 1; cas <= t; cas++) {
    prework();
    mainwork();
    print();
  }
  return 0;
}
