#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
const int mod=19930726;
struct node{
int len,fail,ch[26],siz;
friend bool operator <(node a,node b) {
return a.len>b.len;
}
}prt[N];
int n,num,len,lst;
char s[N];
int getfail(int x) {
while(s[n-prt[x].len-1]!=s[n]) x=prt[x].fail;
return x;
}
void extand(int x) {
int cur=getfail(lst);
int now=prt[cur].ch[x];
if(!now) {
now=++num;
prt[now].len=prt[cur].len+2;
prt[now].fail=prt[getfail(prt[cur].fail)].ch[x];
prt[cur].ch[x]=now;
}
prt[now].siz++;
lst=now;
}
void calc() {
for(int i=num;i>=2;i--)
prt[prt[i].fail].siz+=prt[i].siz;
}
int main() {
num=lst=1,prt[1].len=-1,prt[0].fail=prt[1].fail=1;
scanf("%d",&len);
scanf("%s",s+1);
for(n=1;n<=len;n++) extand(s[n]-'a');
calc();
}