#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ")";
}
string to_string(const string& s) { return '"' + s + '"'; }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(char c) { return to_string(string(1, c)); }
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& a : v) {
    if (!first) res += ", ";
    first = false;
    res += to_string(a);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename A, typename... B>
void debug_out(A a, B... b) {
  cerr << to_string(a);
  if (sizeof...(b)) cerr << ", ";
  debug_out(b...);
}
int solve(vector<int>& a, int c) {
  42;
  if (a.size() <= 2 || c == 0) return a.size();
  vector<int> zeros;
  vector<int> ones;
  int mask = 1 << c;
  int n = (int)a.size();
  for (int i = 0; i < n; i++) {
    if ((a[i] & mask) == 0)
      zeros.push_back(a[i]);
    else
      ones.push_back(a[i]);
  }
  int zz = solve(zeros, c - 1);
  int oo = solve(ones, c - 1);
  if (zz <= 1 || oo <= 1) return zz + oo;
  return max(zz, oo) + 1;
}
int main() {
  cin.tie(0);
  cin.exceptions(cin.failbit);
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int res = solve(a, 31);
  42;
  cout << n - res << '\n';
}
