{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cstyle type\u003d\"text/css\"\u003e pre { text-align:left; font-family: \"Courier New\", Courier, monospace; font-size: 16px; white-space: pre; line-height:20px; text-indent: 0px; }\u003c/style\u003e\u003cdiv class\u003d\"pro_desc\"\u003e\n \u003cp\u003e A palindrome is a symmetrical string, that is, a string read identically from left to right as well as from right to left. You are to write a program which, given a string, determines the minimal number of characters to be inserted into the string in order to obtain a palindrome.\u003cbr\u003e \u003cbr\u003e As an example, by inserting 2 characters, the string \"Ab3bd\" can be transformed into a palindrome (\"dAb3bAd\" or \"Adb3bdA\"). However, inserting fewer than 2 characters does not produce a palindrome.\u003cbr\u003e \u003cbr\u003e\u003c/p\u003e\n\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cdiv class\u003d\"pro_desc\"\u003e\n There are several test cases in the input. The first line of each test case contains one integer: the length of the input string N, (3\u0026lt;\u003dN\u0026lt;\u003d5000). The second line contains one string with length N. The string is formed from uppercase letters from `A\u0027 to `Z\u0027, lowercase letters from `a\u0027 to `z\u0027 and digits from `0\u0027 to `9\u0027. Uppercase and lowercase letters are to be considered distinct. \n \u003cbr\u003e \n \u003cbr\u003e A case with N\u003d0 marks the end of input. This case should not be processed.\n \u003cbr\u003e\n\u003c/div\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cdiv class\u003d\"pro_desc\"\u003e\n For each test case, output one integer, which is the desired minimal number.\n \u003cbr\u003e\n\u003c/div\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre\u003e5\r\nAb3bd\r\n0\r\n\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre\u003e2\u003c/pre\u003e"}}]}