/
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 233 点
問題文
高橋君は自分の部屋の照明の状態を N 時間にわたって毎時記録しました。記録は長さ N の文字列 S で表され、 S の i 文字目が o なら i 時間目に照明はついており、 x なら消えていました。
2 時間目から N 時間目までのうち、直前の時間と照明の状態が同じだった時間の数を求めてください。
制約
- 1 \leq N \leq 100
- S は
oとxのみからなる長さ N の文字列
入力
入力は以下の形式で標準入力から与えられる。
N S
- 1 行目には、記録した時間数 N が与えられる。
- 2 行目には、記録を表す文字列 S が与えられる。
出力
直前の時間と状態が同じだった時間の数を 1 行で出力せよ。
入力例 1
6 ooxxox
出力例 1
2
入力例 2
4 oxox
出力例 2
0
入力例 3
5 oooox
出力例 3
3
入力例 4
74 ooxxxxoxoxxooxxxoooooxxxoooxxxooxoxoxoooooooxooxoooxoxxoooxxxooxxxoxoxoxxo
出力例 4
37
入力例 5
6 ooxoxo
出力例 5
1
Score : 233 pts
Problem Statement
Takahashi recorded the state of the lighting in his room every hour for N hours. The record is represented by a string S of length N, where the i-th character of S is o if the light was on during the i-th hour, and x if it was off.
Among the 2-nd through N-th hours, find the number of hours during which the state of the lighting was the same as in the previous hour.
Constraints
- 1 \leq N \leq 100
- S is a string of length N consisting only of
oandx.
Input
The input is given from Standard Input in the following format:
N S
- The first line contains N, the number of hours recorded.
- The second line contains the string S representing the record.
Output
Print the number of hours whose state was the same as the previous hour in one line.
Sample Input 1
6 ooxxox
Sample Output 1
2
Sample Input 2
4 oxox
Sample Output 2
0
Sample Input 3
5 oooox
Sample Output 3
3
Sample Input 4
74 ooxxxxoxoxxooxxxoooooxxxoooxxxooxoxoxoooooooxooxoooxoxxoooxxxooxxxoxoxoxxo
Sample Output 4
37
Sample Input 5
6 ooxoxo
Sample Output 5
1