#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
  ll n, m, k, l, r, mod = 998244353;
  string s;
  l = r = 0;
  cin >> n >> s;
  for (ll i = 0; i < n; ++i) {
    if (s[i] == s[0])
      l++;
    else
      break;
  }
  for (ll i = n - 1; i >= 0; --i) {
    if (s[n - 1] == s[i])
      r++;
    else
      break;
  }
  if (s[0] == s[n - 1])
    cout << ((l + 1) * (r + 1)) % mod;
  else
    cout << (l + r + 1) % mod;
}
