#include <bits/stdc++.h>
using namespace std;
struct Node {
  Node* Zero;
  Node* One;
};
Node* root = new Node();
int dc(Node* u) {
  if (u->Zero == NULL && u->One == NULL) {
    return 1;
  }
  int r, l;
  r = l = 0;
  if (u->Zero != NULL) {
    l = dc(u->Zero);
  }
  if (u->One != NULL) {
    r = dc(u->One);
  }
  int answer = l + r;
  if (r >= 2 && l >= 2) {
    int reduce = min(l, r);
    int sub = reduce - 1;
    answer -= sub;
  }
  return answer;
}
void edge(vector<bool> b) {
  Node* current = root;
  for (int i = 0; i < b.size(); ++i) {
    if (b[i] == 0) {
      if (current->Zero == NULL) current->Zero = new Node();
      current = current->Zero;
    } else {
      if (current->One == NULL) current->One = new Node();
      current = current->One;
    }
  }
}
void solve() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    vector<bool> b;
    for (int j = 30; ~j; j--) {
      if ((1 << j) & x)
        b.push_back(1);
      else
        b.push_back(0);
    }
    edge(b);
  }
  cout << n - dc(root) << '\n';
}
int main() {
  ios::sync_with_stdio(false), cin.tie(nullptr);
  int t = 1;
  while (t--) solve();
  return 0;
}
