#include <bits/stdc++.h>
using namespace std;
void usaco(string s) {
  freopen((s + ".in").c_str(), "r", stdin);
  freopen((s + ".out").c_str(), "w", stdout);
}
template <class T>
void umin(T &a, T b) {
  if (b < a) a = b;
}
template <class T>
void umax(T &a, T b) {
  if (a < b) a = b;
}
int rec(vector<int> &v, int bit) {
  if (v.size() < 3 || bit < 0) return v.size();
  vector<int> vec[2];
  for (int x : v) vec[x >> bit & 1].push_back(x);
  int x = rec(vec[0], bit - 1);
  int y = rec(vec[1], bit - 1);
  if (x < y) swap(x, y);
  return x + !!y;
}
int main() {
  int n;
  scanf("%d", &n);
  vector<int> v;
  for (int i = 0; i ^ n; i++) {
    int x;
    scanf("%d", &x);
    v.push_back(x);
  }
  printf("%d", n - rec(v, 30));
}
