B. Substring Removal

You are given a string ss of length nn consisting only of lowercase Latin letters.

A substring of a string is a contiguous subsequence of that string. So, string "forces" is substring of string "codeforces", but string "coder" is not.

Your task is to calculate the number of ways to remove exactly one substring from this string in such a way that all remaining characters are equal (the number of distinct characters either zero or one).

It is guaranteed that there is at least two different characters in ss.

Note that you can remove the whole string and it is correct. Also note that you should remove at least one character.

Since the answer can be rather large (not very large though) print it modulo 998244353998244353.

If you are Python programmer, consider using PyPy instead of Python when you submit your code.

Input

The first line of the input contains one integer nn (2≤n≤2⋅1052≤n≤2⋅105) — the length of the string ss.

The second line of the input contains the string ss of length nn consisting only of lowercase Latin letters.

It is guaranteed that there is at least two different characters in ss.

Output

Print one integer — the number of ways modulo 998244353998244353 to remove exactly one substring from ss in such way that all remaining characters are equal.

Examples

input

4
abaa

output

6

input

7
aacdeee

output

6

input

2
az

output

3

 

代码:

#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define mem(a,b) memset(a,b,sizeof(a))
#define closeio std::ios::sync_with_stdio(false)
#define Mod 998244353

int main()
{
	string s;
	ll n,i,l,r,sum;
	cin>>n;
	cin>>s;
	l=1;
	r=1;
	for(i=0;i<n;i++)
	{
		if(s[i]==s[i+1])
			l++;
		else
			break;
	}
	for(i=n-1;i>=0;i--)
	{
		if(s[i]==s[i-1])
			r++;
		else
			break;
	}
	sum=1;
	if(s[0]==s[n-1])
		sum+=(l+r+l*r%Mod)%Mod;
	else
		sum+=(l+r)%Mod;
	cout<<sum<<endl;
	return 0;
}