#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int length;
  string s;
  cin >> length;
  cin >> s;
  long long int x = 1;
  while (x < length) {
    if (s[x] != s[0]) break;
    x++;
  }
  long long int ans;
  long long int y = length - 2;
  while (y >= 0) {
    if (s[y] != s[length - 1]) break;
    y--;
  }
  y = length - y - 1;
  if (s[0] != s[length - 1]) {
    ans = (x + y + 1) % 998244353;
  } else {
    ans = (x + 1) * (y + 1) % 998244353;
  }
  cout << ans;
}
