/
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 233 点
問題文
宮殿の廊下は横一列に並んだ N 個のマスからなり、左から i 番目のマスの様子は文字列 S の i 文字目で表されます。 G はそのマスに衛兵が立っていることを、 . は誰もいないことを表します。
衛兵は、自分の立っているマスと、その左右に隣り合うマス(存在するもののみ)を守ります。
どの衛兵にも守られていないマスの数を求めてください。
制約
- 1 \leq N \leq 100
- S は
Gと.のみからなる長さ N の文字列
入力
入力は以下の形式で標準入力から与えられる。
N S
- 1 行目には、マスの数 N が与えられる。
- 2 行目には、廊下の様子を表す文字列 S が与えられる。
出力
どの衛兵にも守られていないマスの数を 1 行で出力せよ。
入力例 1
5 .G...
出力例 1
2
入力例 2
5 .....
出力例 2
5
入力例 3
3 G.G
出力例 3
0
入力例 4
54 .G..GG..G...G.G...G.....GG.....G.G....GG.GG..G...G....
出力例 4
14
入力例 5
30 ..GG.G.G....GG..G...G.........
出力例 5
12
Score : 233 pts
Problem Statement
The corridor of a palace consists of N cells arranged in a row, and the state of the i-th cell from the left is represented by the i-th character of a string S. G means a guard is standing on that cell, and . means nobody is there.
Each guard protects the cell they are standing on and the cells immediately to its left and right (only those that exist).
Find the number of cells that are not protected by any guard.
Constraints
- 1 \leq N \leq 100
- S is a string of length N consisting only of
Gand..
Input
The input is given from Standard Input in the following format:
N S
- The first line contains N, the number of cells.
- The second line contains the string S representing the state of the corridor.
Output
Print the number of cells not protected by any guard on a single line.
Sample Input 1
5 .G...
Sample Output 1
2
Sample Input 2
5 .....
Sample Output 2
5
Sample Input 3
3 G.G
Sample Output 3
0
Sample Input 4
54 .G..GG..G...G.G...G.....GG.....G.G....GG.GG..G...G....
Sample Output 4
14
Sample Input 5
30 ..GG.G.G....GG..G...G.........
Sample Output 5
12