#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e4 + 5;
const int mod = 998244353;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  string s;
  cin >> n >> s;
  long long st = 0, ed = 0;
  for (int i = 0; i < n; i++) {
    if (s[0] == s[i])
      st++;
    else
      break;
  }
  if (st == n) {
    cout << ((n * (n + 1) * 1LL) / 2LL) % mod << endl;
    return 0;
  }
  for (int i = n - 1; i >= 0; i--) {
    if (s[n - 1] == s[i])
      ed++;
    else
      break;
  }
  if (s[0] != s[n - 1]) {
    cout << (st + ed + 1) % mod << endl;
    return 0;
  }
  cout << ((st + 1) * (ed + 1)) % mod << endl;
  return 0;
}
