#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define TEST int t;cin>>t;while(t--)
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fr first
#define sc second
#define popcount __builtin_popcountll
#define IOS ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
const ll mod=1000000007;
typedef vector<int,int> p1;
typedef vector<ll,ll> p2;
int main()
{
IOS;
//TEST{
int n;
cin>>n;
string s;
cin>>s;
char a=s[0],b=s[s.length()-1];
int id=-1;
for(int i=1;i<s.length();i++){
if(s[i]==s[0]&&s[i+1]==s[1])id=i;
}
if(id!=-1)cout<<n-2;
else cout<<0;
cout<<endl;
//}
return 0;
}
Copy