#include <bits/stdc++.h>
using namespace std;
template <class T>
T gcd(T a, T b) {
  return (b == 0) ? a : gcd(b, a % b);
}
const unsigned int MOD = 1000000007;
template <class T>
T power(T a, long long int n) {
  T res = 1;
  while (n > 0) {
    if (n % 2) res = (res * a) % MOD;
    a = (a * a) % MOD, n = n / 2;
  }
  return res % MOD;
}
unsigned int factorial(unsigned int n) {
  if (n == 0) return 1;
  return n * factorial(n - 1);
}
long long int nCr(long long int n, long long int r) {
  long long int p = r;
  long long int q = 1;
  while (p--) q = q * n, n--;
  return (q / factorial(r));
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n;
  cin >> n;
  string s;
  cin >> s;
  long long int mod = 998244353;
  if (s.front() != s.back()) {
    char p = s[0];
    long long int i = 0;
    long long int temp = 0, ans = 0;
    while (p == s[i]) temp++, i++;
    ans += temp;
    i = s.length() - 1;
    p = s[i];
    temp = 0;
    while (p == s[i]) temp++, i--;
    ans += temp;
    ans++;
    cout << ans % mod;
  } else {
    char p = s[0];
    long long int i = 0;
    long long int temp1 = 0, ans = 0, temp2 = 0;
    while (p == s[i]) temp1++, i++;
    i = s.length() - 1;
    p = s[i];
    while (p == s[i]) temp2++, i--;
    cout << ((temp1 + 1) * (temp2 + 1)) % mod;
  }
}
