#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, M = N * 64 + 5;
int codes[M][2], road[M], cnt = 0;
void insert(int x) {
  int code = 0;
  for (int bit = 30; bit >= 0; --bit) {
    road[code]++;
    int to = (x >> bit & 1);
    if (!codes[code][to]) {
      cnt++;
      codes[code][to] = cnt;
    }
    code = codes[code][to];
  }
  road[code]++;
}
int solve(int code) {
  int code0 = codes[code][0];
  int code1 = codes[code][1];
  if (code0 && code1) {
    return max(solve(code0), solve(code1)) + 1;
  } else {
    if (code0) {
      return solve(code0);
    } else {
      if (code1) {
        return solve(code1);
      } else {
        return 1;
      }
    }
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int x = 0;
    cin >> x;
    insert(x);
  }
  cout << n - solve(0) << '\n';
  return 0;
}
