#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, count = 0;
  cin >> n;
  string s;
  cin >> s;
  if (s[0] != s[n - 1]) {
    long long i = 0;
    while (s[i] == s[i + 1] && i != n - 1) {
      count++;
      i++;
    }
    count++;
    i = n - 1;
    while (s[i] == s[i - 1] && i != 0) {
      count++;
      i--;
    }
    count++;
    long long ans = (count + 1) % 998244353;
    cout << ans << endl;
  } else {
    long long i = 0, count1 = 0, count2 = 0;
    while (s[i] == s[i + 1] && i != n - 1) {
      count1++;
      i++;
    }
    count1++;
    long long j = n - 1;
    while (s[j] == s[j - 1] && j != 0) {
      count2++;
      j--;
    }
    count2++;
    long long ans =
        ((count1 * (count2 + 1)) % 998244353 + count2 + 1) % 998244353;
    cout << ans << endl;
  }
  return 0;
}
