#include <iostream>

using namespace std;

int maximum(int x, int y, int z) {
	int m = x;
	if (y > m)
		m = y;
	if (z > m)
		m = z;
	return m;
}
int main()
{
	int n, m, s = 0, i = 0, o = 0;
	cin >> n;
	char a[n - 1][3];
	for (int i = 0; i < n; i++){
			cin >> a[i][0] >> a[i][1] >> a[i][2];
			if (a[i][2] == 'S') s++;
			if (a[i][2] == 'I') i++;
			if (a[i][2] == 'O') o++;
	}
	m = maximum(s, i, o);
	cout << m;
	return 0;
}