#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  long long int counter = 1;
  long long int counter1 = 1;
  char arr[t + 1];
  cin >> arr;
  long long int ans = 3;
  for (long long int i = 0; i < t; i++) {
    if (arr[i] == arr[i + 1]) {
      ans++;
      counter++;
    } else {
      break;
    }
  }
  for (long long int j = t - 1; j > -1; j--) {
    if (arr[j] == arr[j - 1]) {
      ans++;
      counter1++;
    } else {
      break;
    }
  }
  if (arr[0] == arr[t - 1]) {
    cout << ((((counter1 + 1) % 998244353) * ((counter + 1) % 998244353))) %
                998244353;
  } else {
    cout << (ans) % 998244353;
  }
}
