#include <bits/stdc++.h>
using namespace std;
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long n;
  string s;
  cin >> n >> s;
  long long ans = 1, cnt1 = 0, cnt2 = 0;
  char c1 = s.front(), c2 = s.back();
  for (long long i = 0; i < n; i++) {
    if (s[i] != c1) {
      break;
    }
    cnt1++;
  }
  for (long long i = n - 1; i >= 0; i--) {
    if (s[i] != c2) {
      break;
    }
    cnt2++;
  }
  long long mod = 998244353;
  if (c1 != c2) {
    cout << ((cnt1 + cnt2 + 1) % mod) << "\n";
  } else {
    cout << (((cnt1 + 1) * 1LL * (cnt2 + 1)) % mod) << "\n";
  }
  return 0;
}
