#include <bits/stdc++.h>
using namespace std;
const int lx = 3e5 + 123;
const long long int mod = 998244353;
void solve() {
  long long int n, i, j, a, b, c;
  string s;
  cin >> n >> s;
  long long int sum = 0;
  char c1 = s[0], c2 = s[n - 1];
  for (i = 1, a = 1; i < n; i++) {
    a++;
    if (s[i] != c1) break;
  }
  for (i = n - 2, b = 1; i >= 0; i--) {
    b++;
    if (s[i] != c2) break;
  }
  if (n == 2)
    cout << 3 << "\n";
  else if (c1 == c2) {
    cout << ((a % mod) * (b % mod)) % mod << endl;
  } else {
    cout << ((a - 1) % mod) + ((b % mod)) % mod << endl;
  }
}
void init_code() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
}
