#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  long long result = 0;
  for (char c = 'a'; c <= 'z'; ++c) {
    int l = n, r = -1;
    for (int i = 0; i < n; ++i) {
      if (s[i] != c) {
        l = min(l, i);
        r = max(r, i);
      }
    }
    r = n - 1 - r;
    if (l == 0 && r == 0) {
      continue;
    }
    if (l > 0 && r > 0) {
      for (int j = 0; j < l; ++j) {
        result += r + 1;
      }
      result += r;
      continue;
    }
    if (l > 0) {
      result += l;
      continue;
    }
    if (r > 0) {
      result += r;
      continue;
    }
  }
  ++result;
  cout << result % 998244353 << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cout << setprecision(12) << fixed;
  solve();
  return 0;
}
