#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int mod = 998244353;
  long long int count_first = 1;
  long long int count_last = 1;
  string str;
  char first;
  char last;
  int n;
  cin >> n;
  cin >> str;
  int flag = 0;
  for (int i = 1; i < str.length(); i++) {
    if (str.at(i) == str.at(0)) {
      count_first++;
    } else {
      flag = 1;
      break;
    }
  }
  if (flag == 0) {
    long long int temp = (n * (n + 1)) / 2;
    temp = temp % mod;
    cout << temp << endl;
    return 0;
  }
  for (int i = str.length() - 2; i >= 0; i--) {
    if (str.at(i) == str.at(str.length() - 1))
      count_last++;
    else
      break;
  }
  if (str.at(0) == str.at(str.length() - 1)) {
    count_first++;
    count_last++;
    long long int x = (count_first * count_last) % mod;
    cout << x << endl;
  } else if (str.at(0) != str.at(str.length() - 1)) {
    long long int x = count_first + count_last + 1;
    x = x % mod;
    cout << x << endl;
  }
  return 0;
}
