#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, l = -1, r = -1, m = 998244353;
  cin >> n;
  string s;
  cin >> s;
  for (long long i = 0; i < n - 1; i++)
    if (s[i] != s[i + 1]) {
      l = i + 1;
      break;
    }
  for (long long i = n - 1; i > 0; i--)
    if (s[i] != s[i - 1]) {
      r = n - i;
      break;
    }
  long long ans = (l % m + r % m + 1) % m;
  if (s[0] == s[n - 1]) ans = (ans % m + ((l % m) * (r % m)) % m) % m;
  cout << ans % m;
  return 0;
}
