answer = 0 lst = ['akai', 'marui', 'okii', 'umai'] n = input() for i in range(0,n): iis = input().split(' ') hits = [ 0, 0, 0, 0 ] for s in iis: if s in lst: ix = lst.index(s) hits[ix] = hits[ix] + 1 amaou = True for j in range(0,4): if hits[j] != 1: amaou = False break if amaou: answer = answer + 1 print(answer)