#include <bits/stdc++.h>
using namespace std;
long long n, l1, l2, res;
bool ok[200002];
string s;
int main() {
  cin >> n >> s;
  l1 = 1;
  int i = 1;
  ok[0] = true;
  while (s[i] == s[0] && i < n) {
    ok[i] = true;
    l1++;
    i++;
  }
  l2 = 1;
  i = n - 2;
  while (s[i] == s[n - 1] && i > -1 && !ok[i]) {
    l2++;
    i--;
  }
  if (s[0] == s[n - 1]) {
    res = (res + ((l1 + 1) * (l2 + 1) % 998244353)) % 998244353;
    cout << res;
  } else {
    cout << l1 + l2 + 1;
  }
  return 0;
}
