#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  string s;
  cin >> s;
  long long int p = 0, q = 0, ans;
  char f = s[0], l = s[s.size() - 1];
  for (int i = 0; i < s.size(); i++) {
    if (f == s[i])
      p++;
    else
      break;
  }
  for (int i = s.size() - 1; i >= 0; i--) {
    if (l == s[i])
      q++;
    else
      break;
  }
  if (f == l) {
    ans = (p * q) % 998244353;
    cout << (1 + p + q + ans) % 998244353 << endl;
  } else
    cout << (1 + p + q) % 998244353 << endl;
}
