#include #include #include char string[400005] = { 0 }; int ispal(char *start, char *end){ while(1){ if(start[0] != end[0]) return 0; if(start > end) return 1; start++; end--; } } int main() { int n; scanf("%d", &n); scanf("%s", string); int len = strlen(string); int start = 0; char *end = string + len - 1; int i; for(i = 0; string[i]; i++){ if(ispal(string + i, end)){ break; } } printf("%d\n", i == len ? len - 1 : i); return 0; }