101841: [AtCoder]ABC184 B - Quizzes

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $200$ points

Problem Statement

Takahashi will answer $N$ quiz questions.
Initially, he has $X$ points. Each time he answers a question, he gains $1$ point if his answer is correct and loses $1$ point if it is incorrect.
However, there is an exception: when he has $0$ points, he loses nothing for answering a question incorrectly.

You will be given a string $S$ representing whether Takahashi's answers are correct.
If the $i$-th character of $S$ from the left is o, it means his answer for the $i$-th question is correct; if that character is x, it means his answer for the $i$-th question is incorrect.
How many points will he have in the end?

Constraints

  • $1 \le N \le 2 \times 10^5$
  • $0 \le X \le 2 \times 10^5$
  • $S$ is a string of length $N$ consisting of o and x.

Input

Input is given from Standard Input in the following format:

$N$ $X$
$S$

Output

Print the number of points Takahashi will have in the end.


Sample Input 1

3 0
xox

Sample Output 1

0

Initially, he has $0$ points.
He answers the first question incorrectly but loses nothing because he has no point.
Then, he answers the second question correctly, gains $1$ point, and now has $1$ point.
Finally, he answers the third question incorrectly, loses $1$ point, and now has $0$ points.
Thus, he has $0$ points in the end. We should print $0$.


Sample Input 2

20 199999
oooooooooxoooooooooo

Sample Output 2

200017

Sample Input 3

20 10
xxxxxxxxxxxxxxxxxxxx

Sample Output 3

0

Input

题意翻译

## 题目翻译 高桥先生先要回答 $N$ 个问题。 其中高桥先生的初始成绩为 $X$,当他回答问题正确时加 $1$ 分,当他回答错误时扣除 $1$ 分。 特殊地,当高桥先生目前的分数是 $0$ 时,即使回答问题错误也不会扣除分数。 高桥先生的答题结果用一个字符串 $S$ 给出,字符串从左至右当第 $i$ 个字符是 `o` 时表示第 $i$ 个回答问题正确,当第 $i$ 个是 `x` 时表示第 $i$ 个问题回答错误。 那么,高桥先生最后的分数是多少? ## 输入格式 输入用以下方式输入: > $ N $ $ X $ $ S $ 第一行给出 $ N $ $ X $。 第二行给出字符串 $ S $。 ## 输出格式 输出高桥先生最终的得分。 ## 提示 ### 限制 * $1 \leq N \leq 2 \times 10^5$ * $0 \leq X \leq 2 \times 10^5$ * $S$ 是由 `o` `x` 构成的长度为 $N$ 的字符串。 ### 样例说明 1 首先,高桥先生初始分数为 $0$,第 $1$ 问回答错误,但因为分数为 $0$ 所以分数不会减少。第 $2$ 问回答正确,分数增加 $1$ 变成 $1$ 分。第 $3$ 问回答不正确,分数减少为 $0$。所以高桥先生最后的分数为 $0$。故输出 $0$。

加入题单

算法标签: