Palindrome
시간 제한1초메모리 제한512 MB
0과 1로 이루어진 문자열에서 문자 하나를 문자열 끝으로 옮기는 연산을 반복해 팰린드롬으로 만들 때 필요한 최소 이동 횟수를 구하고, 불가능하면 -1을 출력한다.
문제
Zenyk bought a string of length n, which contains only 0 and 1 characters. He wants to present it to Marichka, however he knows that she likes only palindromes (strings which read the same backward as forward) and she will be satisfied with just such a gift.
In one hour, Zenyk can change the string by moving any one of its characters to the end of the string. What is the minimum number of hours needed for Zenyk to prepare a gift for Marichka?
입력
The first line contains one integer n (1 ≤ n ≤ 300). The second line contains a string of length n containing only 0 and 1 characters.
출력
If Zenyk succeeds in preparing a gift then print one integer — the minimum number of hours.
If he can’t do that print “-1” (without quotes).