B - 焚き火の火力 解説 /

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 233 点

問題文

高橋君は焚き火をしています。焚き火の火力は整数で表され、最初は 0 です。

高橋君は N 分間、毎分次のどちらかを行い、その記録が長さ N の文字列 S で表されています。

  • S の i 文字目が W なら、 i 分目に薪を 1 本入れます。火力は 3 増えます。
  • S の i 文字目が . なら、 i 分目は何もしません。火力は 1 減ります。ただし、火力が 0 のときはそのまま 0 です。

N 分後の焚き火の火力を求めてください。

制約

  • 1 \leq N \leq 100
  • S は W と . のみからなる長さ N の文字列

入力

入力は以下の形式で標準入力から与えられる。

N
S
  • 1 行目には、時間 N が与えられる。
  • 2 行目には、記録を表す文字列 S が与えられる。

出力

N 分後の火力を 1 行で出力せよ。


入力例 1

5
W.W..

出力例 1

3

入力例 2

3
...

出力例 2

0

入力例 3

4
WWW.

出力例 3

8

入力例 4

24
W..W...W.W...WWWWWW.W...

出力例 4

20

入力例 5

63
WW.W...W..W..W.WWW.WW.W.W..W..WWWWWWW..WWW....WWWW..W.WWWWW.W.W

出力例 5

81

Score : 233 pts

Problem Statement

Takahashi is building a bonfire. Its strength is represented by an integer, which is initially 0.

Over N minutes, he performs one of the following actions each minute, and the record is given as a string S of length N.

  • If the i-th character of S is W, he adds one piece of firewood in the i-th minute. The strength increases by 3.
  • If the i-th character of S is ., he does nothing in the i-th minute. The strength decreases by 1. However, if the strength is 0, it remains 0.

Find the strength of the bonfire after N minutes.

Constraints

  • 1 \leq N \leq 100
  • S is a string of length N consisting only of W and .

Input

The input is given from Standard Input in the following format:

N
S
  • The first line contains the duration N.
  • The second line contains the string S representing the record.

Output

Print the strength after N minutes on a single line.


Sample Input 1

5
W.W..

Sample Output 1

3

Sample Input 2

3
...

Sample Output 2

0

Sample Input 3

4
WWW.

Sample Output 3

8

Sample Input 4

24
W..W...W.W...WWWWWW.W...

Sample Output 4

20

Sample Input 5

63
WW.W...W..W..W.WWW.WW.W.W..W..WWWWWWW..WWW....WWWW..W.WWWWW.W.W

Sample Output 5

81