#include <bits/stdc++.h>
template <typename Y>
inline bool updmin(Y &a, Y b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename Y>
inline bool updmax(Y &a, Y b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename Y>
inline Y abs(Y a) {
  if (a < 0) a = -a;
  return a;
}
template <typename Y>
inline Y sqr(Y a) {
  return a * a;
}
int read() {
  int w = 1, q = 0, ch = ' ';
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') w = -1;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) q = q * 10 + ch - 48;
  return q * w;
}
inline void FileIO() {
  freopen(
      ""
      ".in",
      "r", stdin);
  freopen(
      ""
      ".out",
      "w", stdout);
}
const int N = 100010, mod = 998244353;
char s[N];
int g[N][3], f[N], n, sum[N];
int main() {
  scanf("%s", s + 1);
  n = (int)strlen(s + 1);
  int tag = 1;
  for (int i = 2; i <= n; i++) {
    if (s[i] == s[i - 1]) {
      tag = 0;
    }
  }
  if (tag) {
    puts("1");
    return 0;
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    sum[i] = (sum[i - 1] + s[i] - 'a' + 1) % 3;
  }
  g[n + 1][0] = g[n + 1][1] = g[n + 1][2] = n + 1;
  for (int i = n; i; i--) {
    for (int j = 0; j < 3; j++) {
      g[i][j] = g[i + 1][j];
    }
    g[i][sum[i]] = i;
  }
  f[0] = 1;
  for (int i = 0; i <= n; i++) {
    for (int j = 1; j <= 2; j++) {
      int nt = g[i + 1][(sum[i] + j) % 3];
      if (nt <= n) {
        f[nt] = (f[nt] + f[i]) % mod;
      }
    }
    if (i && sum[i] == sum[n]) {
      ans = (ans + f[i]) % mod;
    }
  }
  printf("%d\n", ans);
  return 0;
}
