#include<bits/stdc++.h>
using namespace std;


const long long MAXN=5e4;
const long long osn=4294967296;

long long n;
string a[MAXN+10];

pair<string, long long>div(string& x)
{
    long long prenos=0;
    string ans;
    for (long long i=0; i<x.size(); i++)
    {

        long long sum=prenos*10+(x[i]-'0');

        ans.push_back(sum/osn+'0');
        prenos=sum%osn;

    }

    reverse(ans.begin(), ans.end());
    while (ans.size() && ans.back()=='0') ans.pop_back();
    reverse(ans.begin(), ans.end());

    if (ans.size()==0) return {"0", prenos};

    return {ans, prenos};
}


vector<long long>graph[100'000];
long long answer=0;
bool used[100'005];
long long curr=0;
long long usedbits[1605];

long long br=0;

void dfs(long long x)
{
    if (x<=n) used[x]=true;
    else
    {
        usedbits[x-n]=curr;
        br++;
    }

    for (auto next:graph[x])
    {
        if (used[next] || (next>n && usedbits[next-n]==curr)) continue;

        dfs(next);
    }
}

int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    for (long long i=1; i<=n; i++) cin>>a[i];

    for (long long i=1; i<=n; i++)
    {
        long long pos=0;
        while (a[i]!="0")
        {
            //cout<<a[i]<<endl;
            pair<string, long long>p=div(a[i]);

            for (long long j=0; j<32; j++)
            {
                pos++;
                if ((1<<j)&p.second)
                {
                    graph[i].push_back(n+pos+1);
                    graph[n+pos+1].push_back(i);
                }
            }
            a[i]=p.first;
        }
    }

    for (long long i=1; i<=n; i++)
    {
        if (used[i]) continue;
        br=0;
        curr++;
        dfs(i);

        answer=max(answer, br);
    }

    cout<<answer<<endl;
    return 0;
}

