#include <bits/stdc++.h>
using namespace std;
const int maxn = 200010;
const int mod = 998244353;
int n;
char str[maxn];
int cnt[33];
bool check() {
  int has = 0;
  for (int i = 0; i < 26; i++) {
    if (cnt[i] > 0) has++;
  }
  return has <= 1;
}
int main() {
  cin >> n;
  scanf("%s", str);
  long long l = 1;
  for (int i = 1; i < n; i++) {
    if (str[i] == str[i - 1])
      l++;
    else
      break;
  }
  long long r = 1;
  for (int i = n - 2; i >= 0; i--) {
    if (str[i] == str[i + 1])
      r++;
    else
      break;
  }
  long long ans = 0;
  if (l == n) {
    ans = n;
    ans *= (ans + 1);
    ans /= 2;
    ans %= mod;
  } else if (str[0] != str[n - 1]) {
    ans = l + r + 1;
  } else {
    ans = (l + 1) * (r + 1);
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}
