#include <bits/stdc++.h>
using namespace std;
struct Node {
  int val;
  int nc;
  struct Node *l, *r;
};
struct Node *Tree(int val) {
  struct Node *t = new struct Node();
  t->val = val;
  t->nc = 0;
  t->l = t->r = NULL;
  return t;
}
int solve(Node *t) {
  if (t == NULL) {
    return 0;
  }
  int l = solve(t->l);
  int r = solve(t->r);
  return max(l, r) + (l * r > 0 ? 1 : 0) + (l == 0 && r == 0 ? 1 : 0);
}
int main() {
  auto t = Tree(0);
  int n;
  cin >> n;
  int a;
  int ba[32];
  for (int i = 0; i < n; i++) {
    cin >> a;
    for (int j = 31; j >= 0; j--) {
      ba[j] = a % 2;
      a >>= 1;
    }
    auto cur = t;
    for (int j = 0; j < 32; j++) {
      if (ba[j] == 0) {
        if (cur->l == NULL) {
          cur->l = Tree(0);
        }
        cur = cur->l;
        cur->nc++;
      } else {
        if (cur->r == NULL) {
          cur->r = Tree(1);
        }
        cur = cur->r;
        cur->nc++;
      }
    }
  }
  int ans = n - solve(t);
  cout << ans << endl;
  return 0;
}
