#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
long long n, i, x, y, z;
int main() {
  cin >> n;
  string s;
  cin >> s;
  char c = s[0];
  x = 1;
  while (x < n && s[x] == c) x++;
  c = s[n - 1];
  z = 1;
  y = n - 2;
  while (y > 0 && s[y] == c) z++, y--;
  x++, z++;
  if (s[0] == s[n - 1])
    cout << (x * z) % 998244353;
  else
    cout << ((x + z - 1) % 998244353 + 998244353) % 998244353;
}
