#include <bits/stdc++.h>
using namespace std;
int brojac[1000000];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,t=0,br=0,p1=-1,p2=-1;
cin>>n;
char c;
string s,s1="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
cin>>s;
if(n<26)
cout<<0<<endl;
else if(n==26)
{
if(s==s1)
cout<<1<<endl;
else
cout<<0<<endl;
return 0;
}
else if(n==27)
{
if(s[0]!='A'&&s[1]!='A')
{
cout<<0<<endl;
return 0;
}
for(int i=0;i<n;i++)
{
brojac[s[i]]++;
if(brojac[s[i]]>2)
{
cout<<0<<endl;
return 0;
}
else if(brojac[s[i]]==2&&t==1)
{
cout<<0<<endl;
return 0;
}
else if(brojac[s[i]]==2&&t==0)
{
t=1;
c=s[i];
}
}
for(int i=0;i<n;i++)
{
if(p1==-1&&s[i]==c)
p1=i;
else if(p1!=-1&&s[i]==c)
{
p2=i;
break;
}
}
if(s.substr(0,max(0,p1-1))==s1.substr(0,max(0,p1-1))&&s.substr(p1+1,n-(p1+1))==s1.substr(p1,26-p1))
br++;
if(s.substr(0,p2-1)==s1.substr(0,max(0,p2-1))&&s.substr(p2+1,n-(p2+1))==s1.substr(p2,26-p2))
br++;
cout<<br<<endl;
return 0;
}
else
cout<<0<<endl;
return 0;
}