// Justin Almazan
// 6/25/2025
// Solution to 2025 CS SI UCF Contest 3 Problem: Conformity
// https://open.kattis.com/problems/conformity

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

using ll = long long;

ll convertInput() {

    // Converts the input into a unique key (easier for inserting into map)
    vector<ll> v(5);
    for (int i = 0; i < 5; i++) cin >> v[i];

    // Sort to account for the same classes being given in different orders
    sort(v.begin(), v.end());

    // Create the key
    ll res = 0;
    for (int i = 0; i < 5; i++) res = 1000*res + v[i];
    
    // Return the key
    return res;
}

int main() {

    // Get number of frosh
    int n;
    cin >> n;

    // Use a map to store the number of frosh taking a combination of classes
    map<ll, int> m;

    // Insert class combinations into map
    while (n--) m[convertInput()]++;

    // Keeps track of the highest frequency of students taking a class combination, and
    // the number of class combinations with that number of students
    int res = 0, mult = 0;

    // Find the number of students in a most popular combination of courses
    for (auto it = m.begin(); it != m.end(); it++) 
        res = max(res, it->second);

    // Count the number of these combinations of courses
    for (auto it = m.begin(); it != m.end(); it++) 
        mult += (it->second == res);

    // Answer is their product
    cout << res*mult << endl;
    
    return 0;
}