Kaity is the world's biggest IU fan. One day, she is bored and buys I
on them and U
on them. She arranges them on the fridge to spell IU
repeated
Sadly, her archnemesis, Sylvia, has broken into her apartment and rearranged the magnets because she is not an IU fan.
Kaity wants to fix the magnets so that it spells IU repeatedly. Kaity doesn't have a lot of time so in a single operation, she can pick up one magnet and put it between any two adjacent magnets on the fridge or at either end.
Compute the minimum number of operations Kaity needs to make this happen.
Constraints
In tests worth 1 mark,
In tests worth an additional 4 marks,
Input Specification
The first line contains a single integer
The second line contains a string of I
and U
.
Output Specification
Output an integer -1
.
Sample Input
2
IUUI
Sample Output
1
Comments