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

const int maxB = 2005;
bool g[maxB][maxB];
bool visited[maxB];
#define int long long
static const uint64_t BASE10 = 1000000000ULL;
const long long step = (1LL << 32);
void mul_add(vector<int> &a, int chunk) {
	int carry = chunk;
	for (int i = 0; i < (int)a.size(); i++)
	{
		long long curr = (long long)a[i] * BASE10 + carry;
		a[i] = curr % step;
		carry = curr / step;
	}
	if (carry) a.push_back(carry);
}
vector <int> decimal_to_words(const string &s) {
	vector<int> a(1, 0);

	int n = s.size();
	int first = n % 9;
	if (first == 0) first = 9;

	int chunk = stoi(s.substr(0, first));
	mul_add(a, chunk);

	for (int i = first; i < n; i += 9) {
		chunk = stoi(s.substr(i, 9));
		mul_add(a, chunk);
	}

	return a;
}
void parse(string &s) {
    vector<int> words = decimal_to_words(s);

    vector<int> bits;

    for (size_t w = 0; w < words.size(); ++w) {
        int v = words[w];
        for (int i = 0; i < 32; i++) {
			if ((v >> i) & 1) {
				int pos = 32 * w + i;
				if (pos < maxB)
					bits.push_back(pos);
			}
		}
    }

    if (bits.empty()) return;

    int first = bits.front();
    visited[first] = false;

    for (size_t i = 1; i < bits.size(); i++) {
        int b = bits[i];
        visited[b] = false;
        g[first][b] = true;
        g[b][first] = true;
    }
}

int cnt;
void dfs(int v) {
    visited[v] = true;
    cnt++;
    for (int i = 0; i < maxB; i++) {
        if (g[v][i] && !visited[i]) {
            dfs(i);
        }
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;

    fill(visited, visited + maxB, true);

    string s;
    for (int i = 0; i < n; i++) {
        cin >> s;
        parse(s);
    }

    int ans = 0;
    for (int i = 0; i < maxB; i++) {
        if (!visited[i]) {
            cnt = 0;
            dfs(i);
            ans = max(ans, cnt);
        }
    }

    cout << ans << "\n";
}
