#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, i, ans, st, ed;
  cin >> n;
  string s;
  cin >> s;
  st = 1, ed = 1;
  for (i = 1; i < n; i++) {
    if (s[i] == s[i - 1])
      st++;
    else
      break;
  }
  for (i = n - 2; i >= 0; i--) {
    if (s[i] == s[i + 1])
      ed++;
    else
      break;
  }
  if (s[0] == s[n - 1]) {
    ans = ((ed + 1) * (st + 1)) % 998244353;
  } else {
    ans = (st + ed) % 998244353;
    ans = (ans + 1) % 998244353;
  }
  cout << ans << endl;
}
