#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  char s[n];
  cin >> s;
  char start = s[0];
  char end = s[n - 1];
  long long int count1 = 1, count2 = 1, count = 1;
  for (long long int i = 1; i < n; i++) {
    if (start == s[i])
      count1++;
    else
      break;
  }
  for (long long int i = n - 2; i >= 0; i--) {
    if (end == s[i])
      count2++;
    else
      break;
  }
  if (end == start)
    count += count1 * count2 + count1 + count2;
  else
    count += count1 + count2;
  cout << count % 998244353 << endl;
  return 0;
}
