#include <bits/stdc++.h>
using namespace std;
const long long p = 998244353;
int n;
string s;
int main() {
  scanf("%d", &n);
  cin >> s;
  long long t1 = 0;
  while (s[t1] == s[0]) {
    t1++;
  }
  long long t2 = n - 1;
  while (s[t2] == s[n - 1]) {
    t2--;
  }
  t2 = n - t2 - 1;
  if (s[0] != s[n - 1]) {
    printf("%lld", (t1 + t2 + 1) % p);
  } else {
    printf("%lld", (1 + t1) * (1 + t2) % p);
  }
  return 0;
}
