#include <bits/stdc++.h>   using namespace std;   template <typename A, typename B>   string to_string(pair<A, B> p);   template <typename A, typename B, typename C>   string to_string(tuple<A, B, C> p);   template <typename A, typename B, typename C, typename D>   string to_string(tuple<A, B, C, D> p);   string to_string(const string &s) { return     + s +    ; }   string to_string(const char *s) { return to_string((string)s); }   string to_string(bool b) { return (b ?  true  :  false ); }   string to_string(vector<bool> v) {     bool first = true;     string res =  { ;     for (int i = 0; i < static_cast<int>(v.size()); i++) {       if (!first) {         res +=  ,  ;       }       first = false;       res += to_string(v[i]);     }     res +=  } ;     return res;   }   template <size_t N>   string to_string(bitset<N> v) {     string res =   ;     for (size_t i = 0; i < N; i++) {       res += static_cast<char>( 0  + v[i]);     }     return res;   }   template <typename A>   string to_string(A v) {     bool first = true;     string res =  { ;     for (const auto &x : v) {       if (!first) {         res +=  ,  ;       }       first = false;       res += to_string(x);     }     res +=  } ;     return res;   }   template <typename A, typename B>   string to_string(pair<A, B> p) {     return  (  + to_string(p.first) +  ,   + to_string(p.second) +  ) ;   }   template <typename A, typename B, typename C>   string to_string(tuple<A, B, C> p) {     return  (  + to_string(get<0>(p)) +  ,   + to_string(get<1>(p)) +  ,   +            to_string(get<2>(p)) +  ) ;   }   template <typename A, typename B, typename C, typename D>   string to_string(tuple<A, B, C, D> p) {     return  (  + to_string(get<0>(p)) +  ,   + to_string(get<1>(p)) +  ,  +            to_string(get<2>(p)) +  ,   + to_string(get<3>(p)) +  ) ;   }   void debug() { cerr << endl; }   template <typename Head, typename... Tail>   void debug(Head H, Tail... T) {     cerr <<     << to_string(H);     debug(T...);   }   struct Fast_power {     long long integer(long long n, long long e,                       long long my_mod = 9223372036854775807LL) {       long long ans = 1;       while (e) {         if (e & 1)           ans = (ans * n) % my_mod, e--;         else           n = (n * n) % my_mod, e >>= 1;       }       return ans;     }     long long matrix(vector<vector<long long>> &n, long long e,                      long long my_mod = 9223372036854775807LL);   };   struct Euclidean {     int gcdi(int a, int b) { return b ? gcdi(b, a % b) : a; }     double gcdf(double a, double b, double accuracy) {       return b <= accuracy ? a : gcdf(b, fmod(a, b), accuracy);     }   };   const int maxnD = 200000 + 5;   struct Dijkstra {     struct Edge {       int from, to, dist;     };     struct HeapNode {       int d, u;       bool operator<(const HeapNode &rhs) const { return d > rhs.d; }     };     vector<Edge> edges;     vector<int> G[maxnD];     bool done[maxnD];     int d[maxnD], p[maxnD], n, INF = 0x3f3f3f3f;     void init(int n) {       this->n = n;       for (int i = 0; i <= n; i++) G[i].clear();       edges.clear();     }     void AddEdge(int from, int to, int dist) {       edges.push_back((Edge){from, to, dist});       int m = edges.size();       G[from].push_back(m - 1);     }     void dijkstra(int s) {       priority_queue<HeapNode> q;       memset(d, INF, sizeof(d));       d[s] = 0;       memset(done, 0, sizeof(done));       q.push((HeapNode){0, s});       while (!q.empty()) {         HeapNode x = q.top();         q.pop();         int u = x.u;         if (done[u]) continue;         done[u] = true;         for (int i = 0; i < G[u].size(); i++) {           Edge &e = edges[G[u][i]];           if (d[e.to] > d[u] + e.dist) {             d[e.to] = d[u] + e.dist;             p[e.to] = G[u][i];             q.push((HeapNode){d[e.to], e.to});           }         }       }     }   };   const int INF = 0x3f3f3f3f;   const int maxn = 200000;   int ch[maxn * 20][2] = {0};   int cnt = 0;   void add(int *f) {     int root = 0;     for (int i = 0; i < 31; i++) {       if (!ch[root][f[i]]) ch[root][f[i]] = ++cnt;       root = ch[root][f[i]];     }   }   int dfs(int root) {     int ans = 0;     if (ch[root][0] && ch[root][1])       ans = max(dfs(ch[root][0]), dfs(ch[root][1])) + 1;     else if (ch[root][0])       ans = dfs(ch[root][0]);     else if (ch[root][1])       ans = dfs(ch[root][1]);     else       ans = 1;     return ans;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n;     cin >> n;     int num;     for (int i = 0; i < n; i++) {       cin >> num;       int f[31] = {0}, cur = 0;       while (num) f[cur++] = num % 2, num /= 2;       for (int q = 0; q < 15; q++) swap(f[q], f[31 - q - 1]);       add(f);     }     cout << n - dfs(0) << endl;     return 0;   }