#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
int N;
long long sleft, sright;
string a;
int main() {
  scanf("%d", &N);
  cin >> a;
  for (int i = 0; i < N; i++) {
    if (a[i] == a[0])
      sleft++;
    else
      break;
  }
  for (int i = N - 1; i >= 0; i--) {
    if (a[i] == a[N - 1])
      sright++;
    else
      break;
  }
  long long ans = 0;
  if (a[0] == a[N - 1])
    ans = ((sleft + 1L) * (sright + 1L)) % MOD;
  else
    ans = (sleft % MOD + sright % MOD + 1L) % MOD;
  printf("%lld\n", ans);
  return 0;
}
