#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 998244353;
int n;
string s;
long long int l, r;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> s;
  for (int i = 0; i < n; i++)
    if (s[i] == s[0])
      l++;
    else
      break;
  for (int i = n - 1; i >= 0; i--)
    if (s[i] == s[n - 1])
      r++;
    else
      break;
  if (s[0] == s[n - 1])
    cout << (l + 1) * (r + 1) % MOD;
  else
    cout << (l + r + 1) % MOD;
  return 0;
}
