#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, count = 0;
  cin >> n;
  string s;
  cin >> s;
  char ch;
  ch = s[0];
  int i = 0;
  while (s[i] == ch) i++;
  count = count + i;
  int j = n - 1;
  ch = s[n - 1];
  while (s[j] == ch) j--;
  count = count + n - j - 1;
  if (s[0] == s[n - 1]) count = count + (i) * (n - j - 1);
  count++;
  cout << count % 998244353;
}
