#include <bits/stdc++.h>
using namespace std;
const int zzy = 998244353;
char s[100010];
int flag;
int n;
int nxt[100010][3], dp[100010], sum[100010];
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 2; i <= n; i++)
    if (s[i] == s[i - 1]) flag = 1;
  if (!flag) return puts("1"), 0;
  for (int i = 1; i <= n; i++)
    sum[i] = (sum[i - 1] + (s[i] == 'a' ? 1 : 2)) % 3;
  memset(nxt[n + 1], -1, sizeof nxt[n + 1]);
  for (int i = n; i >= 0; i--) {
    memcpy(nxt[i], nxt[i + 1], sizeof nxt[i]);
    if (i) nxt[i][sum[i]] = i;
  }
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    if (sum[i] != 0 && ~nxt[i][0])
      dp[nxt[i][0]] = (dp[nxt[i][0]] + dp[i]) % zzy;
    if (sum[i] != 1 && ~nxt[i][1])
      dp[nxt[i][1]] = (dp[nxt[i][1]] + dp[i]) % zzy;
    if (sum[i] != 2 && ~nxt[i][2])
      dp[nxt[i][2]] = (dp[nxt[i][2]] + dp[i]) % zzy;
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (sum[i] == sum[n]) ans = (ans + dp[i]) % zzy;
  }
  return cout << ans << endl, 0;
}
