#include <bits/stdc++.h>
using namespace std;
const int MAX = 200005;
const int MOD = 998244353;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long i = 0, y = 0, j = 0, k = 0, l = 0, n, req = 0, ans = 0, c1 = 0,
            c2 = 0;
  string s, rs;
  char a;
  cin >> l >> rs;
  s = rs;
  reverse(rs.begin(), rs.end());
  a = s[0];
  for (i = 0; i < l; i++) {
    if (a == s[i])
      c1++;
    else
      break;
  }
  a = rs[0];
  for (i = 0; i < l; i++) {
    if (a == rs[i])
      c2++;
    else
      break;
  }
  n = c1 * c2;
  if (rs[0] == s[0]) {
    ans = c1 + c2 + n + 1;
    ans = ans % MOD;
  } else {
    ans = c1 + c2 + 1;
    ans = ans % MOD;
  }
  cout << ans << endl;
  return 0;
}
