#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T fetch() {
  T ret;
  cin >> ret;
  return ret;
}
template <typename T>
inline vector<T> fetch_vec(long long sz) {
  vector<T> ret(sz);
  for (auto& it : ret) cin >> it;
  return ret;
}
template <typename T>
inline void makeUnique(vector<T>& v) {
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
}
template <typename T>
inline T max_(T a, T b) {
  if (a > b) return a;
  return b;
}
template <typename T>
inline T min_(T a, T b) {
  if (a < b) return a;
  return b;
}
void file() {}
void Match() {}
const long long N = 2e5 + 5;
long long son[N * 32][2], pos = 0, cnt[N * 32];
long long dfs(long long p, long long digit) {
  long long p0 = son[p][0];
  long long p1 = son[p][1];
  if (digit == 0) return max(cnt[p0], cnt[p1]) + (cnt[p0] & cnt[p1]);
  long long num0 = 0, num1 = 0;
  if (p0) num0 = dfs(p0, digit - 1);
  if (p1) num1 = dfs(p1, digit - 1);
  return max(num0, num1) + (num0 && num1);
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ;
  file();
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    long long num, p = 0;
    cin >> num;
    for (long long i = 30; i >= 0; i--) {
      long long& t = son[p][num >> i & 1];
      if (!t) t = ++pos;
      cnt[t]++;
      p = t;
    }
  }
  cout << n - dfs(0, 30) << "\n";
  Match();
  return 0;
}
