// #pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
// #include <x86intrin.h>
using namespace std;
#if __cplusplus >= 202002L
using namespace numbers;
#endif



int main(){
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(ios::badbit | ios::failbit);
	set<string> s{"akai", "marui", "okii", "umai"};
	int n;
	cin >> n;
	int res = 0;
	for(auto i = 0; i < n; ++ i){
		set<string> c;
		for(auto j = 0; j < 4; ++ j){
			string s;
			cin >> s;
			c.insert(s);
		}
		res += c == s;
	}
	cout << res << "\n";
	return 0;
}

/*

*/