#include <bits/stdc++.h>
using namespace std;
char s[200100];
int n;
long long ans;
const int MOD = 998244353;
int main() {
  scanf("%d", &n);
  scanf("%s", s);
  long long l = 1, 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;
  }
  if (s[0] != s[n - 1]) {
    ans = l + r + 1;
    ans %= MOD;
  } else {
    ans = (l + 1) * 1ll * (r + 1);
    ans %= MOD;
  }
  printf("%lld\n", ans);
  return 0;
}
