#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
char s[200005];
int main() {
  int n;
  scanf("%d", &n);
  scanf("%s", s);
  int l = 1;
  int r = 1;
  for (int i = 1; i < n; i++) {
    if (s[i] == s[i - 1])
      l++;
    else
      break;
  }
  for (int i = n - 2; i >= 0; i--) {
    if (s[i] == s[i + 1])
      r++;
    else
      break;
  }
  long long res = 1LL;
  res += l + r;
  if (s[0] == s[n - 1]) res += 1LL * l * r;
  res %= MOD;
  printf("%lld\n", res);
}
