n=int(input())
s = input()
s1= s[::-1]

i = s.find(s1[0])
j,k = i,0
while 1:
    if s[i]!=s1[k]:
        j+=1
        i=j
        k=0
    else:
        if i==len(s)-1:
            print(j)
            break
        i+=1
        k+=1
