#include <bits/stdc++.h>
using namespace std;
const int M = 200010;
int n;
int a[M];
template <typename T>
inline void read(T &x) {
  x = 0;
  char ch = getchar();
  int f = 1;
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') f = -1;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
  x *= f;
}
vector<int> all;
int solve(int now, vector<int> &p) {
  if ((int)p.size() <= 2) return (int)p.size();
  vector<int> l, r;
  for (vector<int>::iterator it = p.begin(); it != p.end(); it++)
    if ((*it >> now) & 1)
      r.push_back(*it);
    else
      l.push_back(*it);
  int ret1 = solve(now - 1, l), ret2 = solve(now - 1, r);
  return max((bool)ret1 + ret2, (bool)ret2 + ret1);
}
int main() {
  read(n);
  for (int i = 1; i <= n; i++) read(a[i]), all.push_back(a[i]);
  printf("%d\n", n - solve(30, all));
  return 0;
}
