#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long n, start = 0, end = 0;
  string a;
  cin >> n >> a;
  for (unsigned long long i = 0; i < n; i++) {
    if (a[i] == a[0])
      start++;
    else
      break;
  }
  for (unsigned long long i = n - 1; i >= 0; i--) {
    if (a[n - 1] == a[i])
      end++;
    else
      break;
  }
  if (a[0] == a[n - 1])
    cout << ((start + 1) * (end + 1)) % 998244353;
  else
    cout << (start + end + 1) % 998244353;
}
