#include <bits/stdc++.h>
using namespace std;
const int INF = ~0U >> 1;
struct IO {
  char buf[(1 << 20)], *p1, *p2;
  char pbuf[(1 << 20)], *pp;
  IO() : p1(buf), p2(buf), pp(pbuf) {}
  ~IO() { fwrite(pbuf, 1, pp - pbuf, stdout); }
  inline char gc() {
    if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, (1 << 20), stdin);
    return p1 == p2 ? ' ' : *p1++;
  }
  inline bool blank(char ch) {
    return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
  }
  template <class T>
  inline void read(T& x) {
    double tmp = 1;
    bool sign = 0;
    x = 0;
    char ch = gc();
    for (; !(ch >= '0' && ch <= '9'); ch = gc())
      if (ch == '-') sign = 1;
    for (; (ch >= '0' && ch <= '9'); ch = gc()) x = x * 10 + (ch - '0');
    if (ch == '.')
      for (ch = gc(); (ch >= '0' && ch <= '9'); ch = gc())
        tmp /= 10.0, x += tmp * (ch - '0');
    if (sign) x = -x;
  }
  inline void read(char* s) {
    char ch = gc();
    for (; blank(ch); ch = gc())
      ;
    for (; !blank(ch); ch = gc()) *s++ = ch;
    *s = 0;
  }
  inline void read(char& c) {
    for (c = gc(); blank(c); c = gc())
      ;
  }
  inline void push(const char& c) {
    if (pp - pbuf == (1 << 20)) fwrite(pbuf, 1, (1 << 20), stdout), pp = pbuf;
    *pp++ = c;
  }
  template <class T>
  inline void write(T x) {
    if (x < 0) x = -x, push('-');
    static T sta[35];
    T top = 0;
    do {
      sta[top++] = x % 10, x /= 10;
    } while (x);
    while (top) push(sta[--top] + '0');
  }
  template <class T>
  inline void write(T x, char lastChar) {
    write(x), push(lastChar);
  }
} io;
template <class T>
inline T Max(const T& a, const T& b) {
  return a > b ? a : b;
}
template <class T>
inline T Min(const T& a, const T& b) {
  return a < b ? a : b;
}
int n;
int calc(int idex, vector<int>& v1) {
  vector<int> v2, v3;
  int size = v1.size();
  if (0 == size) return 0;
  if (-1 == idex) return size;
  for (int i = 0; i < size; ++i)
    if (v1[i] & (1 << idex))
      v2.push_back(v1[i]);
    else
      v3.push_back(v1[i]);
  int res1 = calc(idex - 1, v2);
  int res2 = calc(idex - 1, v3);
  if (0 == res1 || 0 == res2) return max(res1, res2);
  return max(res1, res2) + 1;
}
int main() {
  io.read(n);
  vector<int> vec(n);
  for (int i = 0; i < n; ++i) io.read(vec[i]);
  int res = calc(30, vec);
  io.write(n - res, '\n');
  return 0;
}
