#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
long long n, x = 1, y = 1;
char s[200010];
int main() {
  scanf("%lld", &n);
  scanf("%s", s + 1);
  for (int i = 2; i <= n; i++)
    if (s[i] == s[i - 1])
      x++;
    else
      break;
  if (x == n) {
    printf("%lld", n * (n + 1) / 2 % mod);
    return 0;
  }
  for (int i = n - 1; i > 1; i--)
    if (s[i] == s[i + 1])
      y++;
    else
      break;
  if (s[1] == s[n])
    printf("%lld", (x + 1) * (y + 1) % mod);
  else
    printf("%lld", (x + y + 1) % mod);
  return 0;
}
