#include <bits/stdc++.h>
using namespace std;
const int MD = 998244353;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  string s;
  cin >> n >> s;
  long long int a = 1, b = 1;
  while (s[a] == s[0]) a++;
  while (s[n - 1 - b] == s[n - 1]) b++;
  if (s[0] == s[n - 1])
    cout << (a + 1) * (b + 1) % MD;
  else
    cout << a + b + 1;
  return 0;
}
