#include <bits/stdc++.h>
using namespace std;
long long int mod = 998244353;
bool check(pair<long long int, long long int> p1,
           pair<long long int, long long int> p2) {
  return p2.second > p1.second;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  string s;
  cin >> s;
  bool alls = true;
  for (int i = 0; i < n - 1; i++) {
    if (s[i] != s[i + 1]) {
      alls = false;
      break;
    }
  }
  if (alls) {
    long long int ans = 1;
    ans *= (n + 1);
    ans *= n;
    ans /= 2;
    ans %= mod;
    cout << ans;
    return 0;
  }
  if (s[0] == s[n - 1]) {
    int front = 1, back = 1;
    for (int i = 1; i < n; i++) {
      if (s[i] == s[i - 1]) {
        front++;
      } else {
        break;
      }
    }
    for (int i = n - 2; i >= 0; i--) {
      if (s[i] == s[i + 1]) {
        back++;
      } else {
        break;
      }
    }
    long long int ans = 1 * (front + 1);
    ans *= (back + 1);
    ans %= mod;
    cout << ans;
    return 0;
  }
  int front = 1, back = 1;
  for (int i = 1; i < n; i++) {
    if (s[i] == s[i - 1]) {
      front++;
    } else {
      break;
    }
  }
  for (int i = n - 2; i >= 0; i--) {
    if (s[i] == s[i + 1]) {
      back++;
    } else {
      break;
    }
  }
  cout << (front + back + 1) % mod;
  return 0;
}
