#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
typedef struct data {
  data* bit[2];
  long long cnt = 0;
} trie;
trie* head;
void insert(long long x) {
  trie* node = head;
  for (long long i = 30; i >= 0; i--) {
    long long curbit = (x >> i) & 1;
    if (node->bit[curbit] == NULL) {
      node->bit[curbit] = new trie();
    }
    node = node->bit[curbit];
    node->cnt++;
  }
}
void remove(long long x) {
  trie* node = head;
  for (long long i = 30; i >= 0; i--) {
    long long curbit = (x >> i) & 1;
    node = node->bit[curbit];
    node->cnt--;
  }
}
long long minxor(long long x) {
  trie* node = head;
  long long ans = 0;
  for (long long i = 30; i >= 0; i--) {
    long long curbit = (x >> i) & 1;
    if (node->bit[curbit] != NULL && node->bit[curbit]->cnt > 0)
      node = node->bit[curbit];
    else {
      ans += (1LL << i);
      node = node->bit[curbit ^ 1];
    }
  }
  return ans;
}
long long dp(trie* cur) {
  if (cur->cnt == 1) return cur->cnt;
  if (cur->bit[0] == NULL)
    return dp(cur->bit[1]);
  else if (cur->bit[1] == NULL)
    return dp(cur->bit[0]);
  else
    return 1 + max(dp(cur->bit[0]), dp(cur->bit[1]));
}
long long n, sz;
long long a[N];
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  head = new trie();
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    insert(a[i]);
  }
  cout << n - dp(head);
  return 0;
}
