#include <bits/stdc++.h>
using namespace std;
const long long int modulo = 998244353;
int main() {
  long long int n;
  cin >> n;
  string s;
  cin >> s;
  long long int k1, k2;
  for (long long int i = 0; i + 1 < n; i++) {
    if (s[i] != s[i + 1]) {
      k1 = i;
      break;
    }
  }
  for (long long int i = n - 1; i - 1 >= 0; i--) {
    if (s[i] != s[i - 1]) {
      k2 = i;
      break;
    }
  }
  if (s[0] != s[n - 1]) {
    cout << (1 + (k1 + 1) + (n - k2)) % modulo;
    return 0;
  }
  cout << (((k1 + 1) + 1) * ((n - k2) + 1)) % modulo;
  return 0;
}
