#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)(2e5) + 7;
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
const double eps = 1e-6;
long long ans, l, r;
int n;
char s[maxn], chl, chr;
int main() {
  scanf("%d", &n);
  scanf("%s", (s + 1));
  chl = s[1], chr = s[n];
  for (int i = 1; i <= n; i++) {
    if (s[i] == chl)
      l++;
    else
      break;
  }
  for (int i = n; i >= 1; i--) {
    if (s[i] == chr)
      r++;
    else
      break;
  }
  if (chl == chr)
    ans = (l + 1) * (r + 1) % mod;
  else
    ans = (1 + l + r) % mod;
  printf("%lld", ans % mod);
  return 0;
}
