#include <bits/stdc++.h>
int main() {
  static char s[200000 + 1];
  int n, i, j, cnt;
  scanf("%d%s", &n, s);
  for (i = 0; i < n && s[i] == s[0]; i++)
    ;
  for (j = n - 1; j >= 0 && s[j] == s[n - 1]; j--)
    ;
  cnt = 1 + i + n - 1 - j;
  if (s[0] == s[n - 1]) cnt = (cnt + (long long)i * (n - 1 - j)) % 998244353;
  printf("%d\n", cnt);
  return 0;
}
