#include <bits/stdc++.h>
using namespace std;
int n, cl, cr;
string s;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> s;
  for (int i = 0; i < n; i++) {
    if (s[i] == s[0]) {
      cl++;
    } else {
      break;
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == s[n - 1]) {
      cr++;
    } else {
      break;
    }
  }
  if (s[0] == s[n - 1]) {
    cout << (1LL * (cl + 1) * (cr + 1)) % 998244353;
  } else {
    cout << (cl + cr + 1) % 998244353;
  }
  return 0;
}
