#include <bits/stdc++.h>
using namespace std;
long long N, Ans;
string str;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> str;
  char H = str[0], T = str[N - 1];
  long long HN = 1;
  while (str[HN] == H) HN++;
  long long TN = 1;
  while (str[N - TN - 1] == T) TN++;
  if (H == T) {
    Ans = (HN + 1) * (TN + 1) % 998244353;
  } else {
    Ans = (HN + TN + 1) % 998244353;
  }
  cout << Ans << '\n';
  return 0;
}
