Edward Elric, the Fullmetal Alchemist.
Edward Elric has gloves, each of which we know the specific size and whether it is a right or left glove.
It is possible to pair together two gloves if they have the same size, and if they are gloves of the opposite hands. What is the maximum number of pairs that Edward can make?
Constraints
- , where is the number of gloves Edward has.
- , is the size of a glove.
- Right or left gloves will be described with the character , where can only be
R
(right) orL
(left).
Input Specification
The first line of input will contain a single integer, .
The next lines will contain an integer and a character , separated by a space.
Output Specification
Output a single integer, the number of pairs that can be made with the gloves Edward has.
Sample Input 1
5
2 L
1 R
1 L
2 R
3 L
Sample Output 1
2
Sample Input 2
5
2 L
1 R
1 L
2 R
1 L
Sample Output 2
2
Comments