#include <bits/stdc++.h>
using namespace std;
inline int qr() {
  int f = 0, fu = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') fu = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    f = (f << 3) + (f << 1) + c - 48;
    c = getchar();
  }
  return f * fu;
}
const int N = 2e5 + 10, H = 30;
struct Trie {
  int ch[N * H][2], tot;
  int cnt[N * H];
  inline void insert(int x) {
    int p = 0;
    for (int i = H, id; ~i; i--) {
      id = x >> i & 1;
      if (!ch[p][id]) {
        ch[p][id] = ++tot;
        memset(ch[tot], 0, sizeof(ch[tot]));
      }
      p = ch[p][id];
    }
    cnt[p]++;
  }
  inline int bfs() {
    int ans = 0;
    queue<pair<int, int> > q;
    q.push({1, cnt[0]});
    while (!q.empty()) {
      pair<int, int> x = q.front();
      q.pop();
      if (!ch[x.first][0] && !ch[x.first][1]) {
        ans = max(ans, x.second);
        continue;
      }
      if (ch[x.first][0])
        q.push({ch[x.first][0],
                x.second + cnt[ch[x.first][0]] + (ch[x.first][1] ? 1 : 0)});
      if (ch[x.first][1])
        q.push({ch[x.first][1],
                x.second + cnt[ch[x.first][1]] + (ch[x.first][0] ? 1 : 0)});
    }
    return ans;
  }
} tr;
int n;
int main() {
  n = qr();
  for (register int i = 1; i <= n; ++i) tr.insert(qr());
  printf("%d\n", n - tr.bfs());
  return 0;
}
