#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int count1 = 1, count2 = 1, i = 1;
  while (i < n && s[i] == s[i - 1]) {
    i++;
    count1++;
  }
  int mod = 998244353, j = n - 2;
  while (j >= i && s[j] == s[j + 1]) {
    count2++;
    j--;
  }
  int res = 0;
  if (s[0] == s[n - 1])
    res = (((long long int)(count1 + 1)) * (count2 + 1)) % mod;
  else
    res = count1 + 1 + count2;
  cout << res << endl;
  return 0;
}
