#include <bits/stdc++.h>
using namespace std;
vector<long long> v;
int main() {
  long long len, cnt, i;
  string s = "";
  cin >> len >> s;
  cnt = 1;
  i = 1;
  while (i < len) {
    if (s[i] != s[i - 1]) {
      v.push_back(cnt);
      cnt = 1;
    } else
      cnt++;
    i++;
  }
  v.push_back(cnt);
  char st = s[0], en = s[len - 1];
  if (v.size() == 1) {
    cout << v[0] + 1 << endl;
  } else {
    if (st == en)
      cnt = ((v[0] + 1) * (v[v.size() - 1] + 1)) % 998244353;
    else
      cnt = v[0] + v[v.size() - 1] + 1;
    cout << cnt << endl;
  }
  return 0;
}
