#include <bits/stdc++.h>
using namespace std;
void input(long long int n, long long int a[]) {
  for (long long int i = 0; i < n; ++i) cin >> a[i];
}
long long int bin_expo(long long int A, long long int B, long long int M) {
  long long int res = 1LL;
  while (B > 0) {
    if (B % 2 == 1) {
      res = (res * A) % M;
    }
    A = (A * A) % M;
    B = B / 2;
  }
  return res;
}
bool isPrime[200005 + 1];
void sieve() {
  long long int i, j;
  memset(isPrime, true, sizeof(isPrime));
  isPrime[1] = false;
  isPrime[0] = false;
  for (i = 2; i * i <= 200005; i++) {
    if (isPrime[i] == true) {
      for (j = i * i; j <= 200005; j = j + i) isPrime[j] = false;
    }
  }
}
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
  return (a * b) / gcd(a, b);
}
double distance(long long int x1, long long int y1, long long int x2,
                long long int y2) {
  return sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2) * 1.0);
}
signed main() {
  ios_base::sync_with_stdio(0);
  long long int n, i, j;
  cin >> n;
  string s;
  cin >> s;
  if (n == 1) {
    cout << 2 << endl;
    return 0;
  } else if (n == 2) {
    cout << 3 << endl;
    return 0;
  }
  for (i = 0; i < n; i++) {
    if (s[i] != s[0]) break;
  }
  for (j = n - 1; j >= 0; j--) {
    if (s[j] != s[n - 1]) break;
  }
  long long int ans = 0;
  j = n - j - 1;
  ans = i + j + 1;
  if (s[0] == s[n - 1]) {
    ans = (ans + ((j % 998244353) * (i % 998244353)) % 998244353) % 998244353;
  }
  cout << ans << endl;
  return 0;
}
