#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll mod = 998244353;
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  ll l = 1, r = 1;
  for (int i = 1; i < n; i++) {
    if (s[i] == s[0])
      l++;
    else
      break;
  }
  for (int i = n - 2; i >= 0; i--) {
    if (s[i] == s.back())
      r++;
    else
      break;
  }
  if (s[0] == s.back()) {
    cout << (l + 1) * (r + 1) % mod;
  } else {
    cout << (l + r + 1) % mod;
  }
}
