#!/usr/bin/env python3 # %% import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from heapq import heappop, heappush # %% N, M = map(int, readline().split()) L_to_IRT = [[] for _ in range(N+1)] for i in range(M): L, R, T = readline().decode().split() L = int(L) R = int(R) L_to_IRT[L].append((i,R,T)) # %% q = [] Y = 0 K = 0 C = 0 for L, IRT in enumerate(L_to_IRT): for x in IRT: heappush(q, x) while q and q[0][1] < L: heappop(q) if not q: continue x = q[0][2] if x == 'Y': Y += 1 elif x == 'K': K += 1 else: C += 1 # %% print(Y,K,C)