#include <bits/stdc++.h>
using namespace std;
const long long int OO = 2e7;
const double EPS = (1e-7);
int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }
bool sort_p(pair<int, int> a, pair<int, int> b) { return a.first < b.first; }
long long int mod = 998244353;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  int n;
  string s;
  cin >> n >> s;
  int a = 1, b = 1;
  for (int i = (1); i < (int)(((int)((s).size()))); ++i) {
    if (s[i] == s[0])
      a++;
    else
      break;
  }
  for (int i = (((int)((s).size())) - 2); i >= (int)(0); --i) {
    if (s[i] == s[((int)((s).size())) - 1])
      b++;
    else
      break;
  }
  long long int ans = 1 + a + b;
  if (s[0] == s[((int)((s).size())) - 1]) {
    ans = (ans % mod + ((a % mod) * (b % mod)) % mod) % mod;
  }
  cout << ans;
}
