#include <bits/stdc++.h>
using namespace std;
const int mx = 2e5 + 10;
const double eps = 1e-9;
const int inf = 1e9;
const int mod = 998244353;
char a[mx];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n >> a;
  long long ans1 = 0, ans2 = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == a[0]) {
      ans1++;
    } else
      break;
  }
  for (int i = n - 1; i > 0; i--) {
    if (a[i] == a[n - 1]) {
      ans2++;
    } else
      break;
  }
  if (a[0] == a[n - 1]) {
    return cout << ((ans1 + 1) * (ans2 + 1)) % mod, 0;
  } else {
    cout << (ans1 + ans2 + 1) % mod;
  }
}
