Problem:
Score : 300 points

Problem Statement

Takahashi participated in a contest on AtCoder.

The contest had N problems.

Takahashi made M submissions during the contest.

The i-th submission was made for the p_i-th problem and received the verdict S_i (AC or WA).

The number of Takahashi's correct answers is the number of problems on which he received an AC once or more.

The number of Takahashi's penalties is the sum of the following count for the problems on which he received an AC once or more: the number of WAs received before receiving an AC for the first time on that problem.

Find the numbers of Takahashi's correct answers and penalties.

Constraints

N, M, and p_i are integers.

1 \leq N \leq 10^5

0 \leq M \leq 10^5

1 \leq p_i \leq N

S_i is AC or WA.

Input

Input is given from Standard Input in the following format:

N M
p_1 S_1
:
p_M S_M

Output

Print the number of Takahashi's correct answers and the number of Takahashi's penalties.

Sample Input 1

2 5
1 WA
1 AC
2 WA
2 AC
2 WA

Sample Output 1

2 2

In his second submission, he received an AC on the first problem for the first time. Before this, he received one WA on this problem.

In his fourth submission, he received an AC on the second problem for the first time. Before this, he received one WA on this problem.

Thus, he has two correct answers and two penalties.

Sample Input 2

100000 3
7777 AC
7777 AC
7777 AC

Sample Output 2

1 0

Note that it is pointless to get an AC more than once on the same problem.

Sample Input 3

6 0

Sample Output 3

0 0

Solution in Java8 (OpenJDK 1.8.0) (judge verdict: Wrong Answer)

import java.io.*;
import java.math.*;
import java.util.*;
import java.util.stream.*;

class Main {
    public static void main(String[] args) {
        solve();
        Stdin.flush();
    }

    static void solve() {
        int[] inputs = Stdin.receiveIntArray(" ");
        int problemNum = inputs[0];
        int answerNum = inputs[1];

        int[] wrongNums = new int[problemNum];
        boolean[] hasCorrected = new boolean[problemNum];
        Arrays.fill(wrongNums, 0);

        for (int i = 0; i < answerNum; i++) {
            String[] result = Stdin.receiveStringArray(" ");
            int id = Integer.parseInt(result[0]) - 1;
            boolean ac = result[1].equals("AC");

            if (!hasCorrected[id]) {
                if (ac) {
                    hasCorrected[id] = true;
                } else {
                    wrongNums[id]++;
                }
            }
        }

        int correctNum = 0;
        for (boolean bool : hasCorrected)
            if (bool)
                correctNum++;
        int wrongNum = Calculator.arraySum(wrongNums).intValue();

        Stdin.print(correctNum);
        Stdin.print(" ");
        Stdin.println(wrongNum);
    }

    static class ModCalculator {
        static final BigInteger MOD = BigInteger.valueOf((int) 1e9 + 7);
    }

    static class Calculator {
        static BigInteger gcd(BigInteger x, BigInteger y) {
            if (y.subtract(x).signum() > 0) {
                return gcd(y, x);
            }
            if (y.equals(BigInteger.ZERO)) {
                return x;
            }
            return gcd(y, x.remainder(y));
        }

        static BigInteger gcd(int x, int y) {
            return gcd(BigInteger.valueOf(x), BigInteger.valueOf(y));
        }

        static BigInteger gcd(BigInteger[] arr) {
            BigInteger gcd = arr[0];
            for (BigInteger i : arr) {
                gcd = gcd(gcd, i);
            }
            return gcd;
        }

        static BigInteger gcd(int[] arr) {
            BigInteger gcd = BigInteger.valueOf(arr[0]);
            for (int i : arr) {
                gcd = gcd(gcd, BigInteger.valueOf(i));
            }
            return gcd;
        }

        static BigInteger lcm(BigInteger x, BigInteger y) {
            return x.multiply(y).divide(gcd(x, y));
        }

        static BigInteger lcm(int x, int y) {
            return lcm(BigInteger.valueOf(x), BigInteger.valueOf(y));
        }

        static BigInteger lcm(BigInteger[] arr) {
            BigInteger lcm = BigInteger.ONE;
            for (BigInteger i : arr) {
                lcm = lcm(lcm, i);
            }
            return lcm;
        }

        static BigInteger lcm(int[] arr) {
            BigInteger lcm = BigInteger.ONE;
            for (int i : arr) {
                lcm = lcm(lcm, BigInteger.valueOf(i));
            }
            return lcm;
        }

        static int digits(int x) {
            return String.valueOf(x).length();
        }

        static BigInteger arraySum(BigInteger[] arr) {
            BigInteger ret = BigInteger.ZERO;
            for (BigInteger bi : arr) {
                ret = ret.add(bi);
            }
            return ret;
        }

        static BigInteger arraySum(int[] arr) {
            BigInteger ret = BigInteger.ZERO;
            for (int i : arr) {
                ret = ret.add(BigInteger.valueOf(i));
            }
            return ret;
        }
    }

    static class Stdin {
        static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        static final PrintWriter pw = new PrintWriter(System.out);

        enum Delimiter {
            NONE(""), SPACE(" "), DOT("\\."), COMMA(",");

            private String regex;

            private Delimiter(String regex) {
                this.regex = regex;
            }

            public static Delimiter of(String input) {
                try {
                    return Delimiter.valueOf(input);
                } catch (IllegalArgumentException e) {
                    return Arrays.stream(values()).filter(d -> d.getRegex().equals(input)).findFirst().orElse(SPACE);
                }
            }

            public String getRegex() {
                return regex;
            }
        }

        static String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                throw new IllegalArgumentException(e);
            }
        }

        static int receiveInt() {
            return Integer.parseInt(nextLine());
        }

        static BigInteger receiveBigInteger() {
            return new BigInteger(nextLine());
        }

        static char receiveChar() {
            return nextLine().charAt(0);
        }

        static char[] receiveCharArray() {
            return nextLine().toCharArray();
        }

        static int[] receiveIntArray(Delimiter delimiter) {
            String[] inputs = nextLine().split(delimiter.getRegex());
            int[] ret = new int[inputs.length];
            for (int i = 0; i < inputs.length; i++) {
                ret[i] = Integer.parseInt(inputs[i]);
            }
            return ret;
        }

        static int[] receiveIntArray(String delimiterString) {
            return receiveIntArray(Delimiter.of(delimiterString));
        }

        static BigInteger[] receiveBigIntegerArray(Delimiter delimiter) {
            String[] inputs = nextLine().split(delimiter.getRegex());
            BigInteger[] ret = new BigInteger[inputs.length];
            for (int i = 0; i < inputs.length; i++) {
                ret[i] = new BigInteger(inputs[i]);
            }
            return ret;
        }

        static BigInteger[] receiveBigIntegerArray(String delimiterString) {
            return receiveBigIntegerArray(Delimiter.of(delimiterString));
        }

        static String[] receiveStringArray(Delimiter delimiter) {
            return nextLine().split(delimiter.getRegex());
        }

        static String[] receiveStringArray(String delimiterString) {
            return receiveStringArray(Delimiter.of(delimiterString));
        }

        static void print(Object obj) {
            pw.print(obj);
        }

        static void println(Object obj) {
            pw.println(obj);
        }

        static void println() {
            pw.println("");
        }

        static void flush() {
            pw.flush();
        }
    }
}