#include <bits/stdc++.h>
using namespace std;
long long INF = (long long)1e20;
int iINF = (int)1e20;
int main() {
  long long n;
  cin >> n;
  string s;
  cin >> s;
  long long num1 = 1, num2 = 1;
  for (int i = 1; i < n; ++i) {
    if (s[i] != s[i - 1]) break;
    ++num1;
  }
  reverse(s.begin(), s.end());
  for (int i = 1; i < n; ++i) {
    if (s[i] != s[i - 1]) break;
    ++num2;
  }
  if (s[0] != s[n - 1]) {
    cout << num1 + num2 + 1;
    return 0;
  }
  cout << ((num1 + 1) * (num2 + 1)) % 998244353;
}
