#include <bits/stdc++.h>
using namespace std;
const long long MOD = (long long)998244353;
const int SIZE = 3e5 + 5;
const long long INF = 1LL << 60;
const double eps = 1e-4;
const double PI = 3.1415926535897932;
int a[200009];
int main() {
  int(n);
  scanf("%d", &n);
  vector<pair<int, int> > cur, nx;
  for (int i = 0; i < (n); ++i) {
    scanf("%d", &(a[i]));
    cur.push_back({a[i], 1});
  }
  sort((cur).begin(), (cur).end());
  for (int bi = 0; bi < (30); ++bi) {
    int bv = 1 << bi;
    nx.clear();
    for (int i = 0; i < (((int)(cur).size())); ++i) {
      if (i + 1 < ((int)(cur).size()) &&
          (cur[i].first ^ cur[i + 1].first) == bv) {
        if (min(cur[i].second, cur[i + 1].second) > 1) {
          nx.push_back(
              {cur[i].first, max(cur[i].second, cur[i + 1].second) + 1});
        } else {
          nx.push_back({cur[i].first, cur[i].second + cur[i + 1].second});
        }
        i++;
      } else {
        int nv = cur[i].first;
        if (nv & bv) nv ^= bv;
        nx.push_back({nv, cur[i].second});
      }
    }
    swap(nx, cur);
  }
  printf("%d", n - cur[0].second);
}
