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