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