#include <bits/stdc++.h>
using namespace std;
int bit;
int getbit(int i, int arr[]) { return arr[i] >> bit & 1; }
bool comp(int a, int b) { return (a >> bit & 1) < (b >> bit & 1); }
int eligible(int arr[], int start, int end, int bt) {
  if (start == end) return 1;
  if (end - start == 1) return 2;
  bit = bt;
  if (getbit(start, arr) == getbit(end, arr))
    return eligible(arr, start, end, bt - 1);
  int m = upper_bound(arr + start, arr + end + 1, 0, comp) - arr;
  return max(eligible(arr, start, m - 1, bt - 1),
             eligible(arr, m, end, bt - 1)) +
         1;
}
void solve() {
  int n;
  cin >> n;
  int arr[200001];
  for (int i = 0; i < n; i++) cin >> arr[i];
  sort(arr, arr + n);
  cout << n - eligible(arr, 0, n - 1, 30);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  return 0;
}
