#P9811. Jersey Distribution

    ID: 22957 Type: Default 1000ms 256MiB

Jersey Distribution

Jersey Distribution

There are jerseys numbered from \(1\) to \(n\). These jerseys come in three sizes: \(S\), \(M\), and \(L\) in increasing order. You are given \(m\) team members. The \(i\)th team member requires a jersey whose size is not less than \(a_i\) (where \(a_i\) is one of \(S\), \(M\), or \(L\)) and specifically requests the jersey with number \(b_i\). Each jersey can be assigned to at most one team member. Determine the maximum number of team members whose requirements can be satisfied.

inputFormat

The first line contains two integers (n) and (m). Each of the next (m) lines contains a character and an integer, representing the required minimum jersey size (one of S, M, L) and the requested jersey number (b_i), respectively.

outputFormat

Output a single integer representing the maximum number of team members that can be satisfied.

sample

3 3
S 1
M 2
L 3
3