#include <bits/stdc++.h>
using namespace std;
long long Power(long long _a, long long _b) {
  long long _result = 1;
  _a %= 998244353;
  while (_b) {
    if (_b % 2 == 1) _result *= _a;
    _a *= _a;
    _a %= 998244353;
    _result %= 998244353;
    _b /= 2;
  }
  return _result;
}
long long Mod_Inv(long long _a) {
  _a %= 998244353;
  _a = Power(_a, 998244353 - 2);
  return _a;
}
long long Factorial[500001];
long long Make_Factorial() {
  Factorial[0] = 1;
  for (long long i = 1; i < 500001; i++) {
    Factorial[i] = i * Factorial[i - 1];
    Factorial[i] %= 998244353;
  }
  return 0;
}
long long Implement_Make_Factorial = Make_Factorial();
long long nCr(long long _n, long long _r) {
  if (_n < _r) return 0;
  long long _ans = Factorial[_n];
  _ans %= 998244353;
  _ans *= Mod_Inv(Factorial[_r]);
  _ans %= 998244353;
  _ans *= Mod_Inv(Factorial[_n - _r]);
  _ans %= 998244353;
  return _ans;
}
long long nPr(long long _n, long long _r) {
  long long _ans = Factorial[_n];
  _ans %= 998244353;
  _ans *= Mod_Inv(Factorial[_n - _r]);
  _ans %= 998244353;
  return _ans;
}
void solve() {
  long long n;
  cin >> n;
  string a;
  cin >> a;
  long long ans = 1;
  long long front = 1;
  long long back = 1;
  for (long long i = 1; i < n; i++) {
    if (a[i] == a[i - 1])
      front++;
    else
      break;
  }
  for (long long i = n - 2; i >= 0; i--) {
    if (a[i] == a[i + 1])
      back++;
    else
      break;
  }
  if (a[0] == a[n - 1])
    ans = (front + 1) * (back + 1);
  else
    ans += front + back;
  cout << ans % 998244353 << endl;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) solve();
  return 0;
}
