hash
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
typedef unsigned long long ull;
inline int idx(char ch)
{
switch(ch)
{
case 'G':return 1;
case 'C':return 2;
case 'A':return 3;
case 'T':return 4;
}
}
const int base=5;
int n;
char s1[60009],s2[60009];
ull po[60009],hs1[60009],hs2[60009];
int main()
{
po[0]=1;for (int i=1;i<=50006;i++) po[i]=po[i-1]*5;
scanf("%d",&n);
scanf("%s",s1+1);
for (int i=1;i<=n;i++)
switch(s1[i])
{
case 'G':s2[i]='C';break;
case 'C':s2[i]='G';break;
case 'A':s2[i]='T';break;
case 'T':s2[i]='A';break;
}
for (int i=1;i<=n;i++) hs1[i]=hs1[i-1]*base+idx(s1[i]);
for (int i=n;i>=1;i--) hs2[i]=hs2[i+1]*base+idx(s2[i]);
int ans=0;
for (int i=1;i<n;i++)
{
int l=0,r=min(n-i,i),mid,tt=0;
while (l<=r)
{
mid=(l+r)>>1;
if (hs1[i+mid]-hs1[i]*po[mid]==hs2[i-mid+1]-hs2[i+1]*po[mid])
tt=mid,l=mid+1;
else r=mid-1;
}
if (tt*2>ans) ans=tt*2;
}
printf("%d",ans);
return 0;
}