#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  string s;
  cin >> s;
  char a = 'a';
  long long ans = 0;
  for (long long i = 0; i < 26; i++) {
    long long findex = -1;
    long long lasindex = -1;
    long long cnta = 0;
    long long cntla = 0;
    for (long long j = 0; j < s.length(); j++) {
      if (s[j] != a) {
        findex = j;
        break;
      } else
        cnta++;
    }
    for (long long j = s.length() - 1; j >= 0; j--) {
      if (s[j] != a) {
        lasindex = j;
        break;
      } else
        cntla++;
    }
    if (findex != -1 && lasindex != -1) {
      long long y = (s.length() - 1 - lasindex + 1) * cnta;
      ans += ((cntla % 998244353) + (y % 998244353)) % 998244353;
    } else {
      long long y = ((cnta - 1) % 998244353 * cnta % 998244353) % 998244353;
      ans += y;
    }
    a++;
  }
  cout << ans + 1 << endl;
  return 0;
}
