#include <bits/stdc++.h>
using namespace std;
long long n;
char a[200100];
long long mod = 998244353;
int main() {
  scanf("%lld", &n);
  scanf("%s", a);
  long long res = 0;
  long long tt = 0;
  while (a[tt] == a[0]) tt++;
  res += (tt + 1);
  long long t1 = 0;
  long long t2 = n - 1;
  while (a[t1] == a[n - 1]) t1++;
  while (a[t2] == a[n - 1]) t2--;
  res += (n - 1 - t2) * (t1 + 1);
  printf("%lld\n", res % mod);
  return 0;
}
