#include <bits/stdc++.h>
using namespace std;
char s[200010];
int main() {
  int n;
  cin >> n;
  scanf("%s", s);
  long long ans = 1;
  long long lcnt = 1;
  for (int i = 1; i < n; i++) {
    if (s[i] == s[0])
      lcnt++;
    else
      break;
  }
  long long rcnt = 1;
  for (int i = n - 1 - 1; i >= 0; i--) {
    if (s[i] == s[n - 1]) {
      rcnt++;
    } else {
      break;
    }
  }
  ans += lcnt;
  ans += rcnt;
  if (s[0] == s[n - 1]) {
    ans += lcnt * rcnt;
  }
  cout << ans % 998244353 << endl;
  return 0;
}
