#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000 + 5;
const int N = 2e5 + 5;
const int M = 30;
const long long oo = LLONG_MAX;
const int mod = 1e9 + 7;
int one[N][M];
int divide(vector<int> v, int bit) {
  if (bit == -1) return (int)v.size();
  vector<int> ones, zeros;
  for (int i = 0; i < (int)v.size(); ++i) {
    int id = v[i];
    if (one[id][bit]) {
      ones.push_back(id);
    } else {
      zeros.push_back(id);
    }
  }
  if (!(int)ones.size() || !(int)zeros.size()) return divide(v, bit - 1);
  int cnt0 = divide(zeros, bit - 1);
  int cnt1 = divide(ones, bit - 1);
  return 1 + max(cnt0, cnt1);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int& x : a) cin >> x;
  for (int i = 0; i < n; ++i) {
    int x = a[i];
    for (int bit = 0; bit < 30; ++bit) {
      if (x & (1 << bit)) {
        one[i][bit] = 1;
      }
    }
  }
  vector<int> v(n);
  for (int i = 0; i < n; ++i) v[i] = i;
  cout << n - divide(v, 29);
  return 0;
}
