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