

Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 250 点
問題文
高橋君は改札機の利用履歴を集計しました。 しかし、高橋君はうっかりいくつかの入退場記録を消してしまいました。 高橋君は消してしまった記録の復元を試みようとしています。
i
, o
のみからなる文字列 S が与えられます。
S の任意の位置に文字を 0 文字以上挿入することで、変更後の文字列が以下の条件を満たすようにしたいです。
- 長さが偶数であり、奇数文字目が
i
で偶数文字目がo
である。
挿入する必要のある文字数の最小値を求めて下さい。なお、問題の制約下で、有限個の文字を適切に挿入することで、S が条件をみたすようにできることが証明できます。
制約
- S は
i
,o
からなる長さ 1 以上 100 以下の文字列
入力
入力は以下の形式で標準入力から与えられる。
S
出力
答えを出力せよ。
入力例 1
ioi
出力例 1
1
3 文字目のあとに o
を挿入して ioio
とすることで、条件を満たすことができます。0 文字以下の挿入で条件を満たすことはできません。
入力例 2
iioo
出力例 2
2
1 文字目のあとに o
を、3 文字目のあとに i
を挿入することで、条件を満たすことができます。1 文字以下の挿入で条件を満たすことはできません。
入力例 3
io
出力例 3
0
S がすでに条件を満たします。
Score : 250 points
Problem Statement
Takahashi aggregated usage records from ticket gates. However, he accidentally erased some records of entering and exiting stations. He is trying to restore the erased records.
You are given a string S consisting of i
and o
. We want to insert zero or more characters at arbitrary positions in S so that the resulting string satisfies the following conditions:
- Its length is even, and every odd-numbered (1st, 3rd, ...) character is
i
while every even-numbered (2nd, 4th, ...) character iso
.
Find the minimum number of characters that need to be inserted. It can be proved under the constraints of this problem that by inserting an appropriate finite number of characters, S can be made to satisfy the conditions.
Constraints
- S is a string of length between 1 and 100, consisting of
i
ando
.
Input
The input is given from Standard Input in the following format:
S
Output
Print the answer.
Sample Input 1
ioi
Sample Output 1
1
We can insert o
after the 3rd character to form ioio
to satisfy the conditions. The conditions cannot be satisfied by inserting zero or fewer characters.
Sample Input 2
iioo
Sample Output 2
2
We can insert o
after the 1st character and i
after the 3rd character to satisfy the conditions. The conditions cannot be satisfied by inserting one or fewer characters.
Sample Input 3
io
Sample Output 3
0
S already satisfies the conditions.