P23588 [AtCoder] Confectionery Shop
普及+
题目描述

Problem Description

You are running a confectionery shop. Today, you have prepared $A$ shortcakes and $B$ cheesecakes.

It is known that $N$ customers will visit the shop today. The behavior of each customer can be represented using a string $X$ of length $N$ consisting of the characters S, C, and E as follows:

  • If the $i$-th character of $X$ is S, the $i$-th customer will buy 1 shortcake, unless they are already sold out when the customer arrives.
  • If the $i$-th character of $X$ is C, the $i$-th customer will buy 1 cheesecake, unless they are already sold out when the customer arrives.
  • If the $i$-th character of $X$ is E, the $i$-th customer will buy 1 of whichever cake (shortcake or cheesecake) has more remaining when they arrive. If both are sold out, they will buy nothing. If both have the same number of cakes remaining, they will buy 1 shortcake.

After all customers have left, how many shortcakes and cheesecakes will be left?

Input Format

The input is given from the standard input in the following format:

$A$ $B$ $N$ $X$

Output Format

Output 2 lines. The first line should contain the number of remaining shortcakes, and the second line should contain the number of remaining cheesecakes.

Sample Input and Output

Sample Input #1

3 2 3
SEC

Sample Output #1

1
1

Sample Input #2

2 4 6
SSSEEE

Sample Output #2

0
1

Sample Input #3

0 3 6
SEECEE

Sample Output #3

0
0

Sample Input #4

100 99 9
SSSEEECCC

Sample Output #4

96
94

Notes/Hints

Constraints

  • $0 \leq A, B \leq 10^5$
  • $1 \leq N \leq 10^5$
  • $|X| = N$
  • Each character in $X$ is either S, C, or E.

Sample Explanation 1

The first 2 customers buy shortcakes, and the last customer buys a cheesecake.

Sample Explanation 2

The third customer cannot buy any cake.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 2 3 SEC
样例输出
1 1