#include <bits/stdc++.h>
using namespace std;
long long mod = 998244353;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  long long cnt1 = 1, cnt2 = 1;
  while (cnt1 < n && s[cnt1] == s[cnt1 - 1]) {
    cnt1++;
  }
  while (n - cnt2 - 1 >= 0 && s[n - cnt2] == s[n - cnt2 - 1]) {
    cnt2++;
  }
  long long ans;
  if (s[0] != s[n - 1])
    ans = cnt1 + cnt2 + 1;
  else
    ans = (cnt1 + 1) * (cnt2 + 1);
  ans %= mod;
  cout << ans;
  return 0;
}
