#include <cstring>
#include <cstdio>
#define MOD 998244353
int dp[200005][3][3][2]; 
char str[200005]; 
int main()
{
	// freopen("ARC094-F.in", "r", stdin); 
	scanf("%s", str);
	int n = strlen(str), cnt = 0, sum = 0; 
	for (int i = 0; i < n; i++)
		(sum += str[i] - 'a') %= 3; 
	for (int i = 1; i < n; i++)
		cnt += str[i] != str[i - 1]; 
	if (!cnt)
	{
		puts("1"); 
		return 0;
	}
	if (n <= 3)
	{
		if (n == 2)
			puts("2"); 
		else
		{
			if (cnt != n - 1)
				puts("6"); 
			else if (str[0] == str[2])
				puts("7"); 
			else
				puts("3"); 
		}
		return 0; 
	}
	dp[1][0][0][0] = dp[1][1][1][0] = dp[1][2][2][0] = 1; 
	for (int i = 1; i < n; i++)
	{
		for (int x = 0; x < 3; x++)
		{
			for (int y = 0; y < 3; y++)
			{
				for (int t = 0; t < 2; t++)
				{
					for (int z = 0; z < 3; z++)
						(dp[i + 1][z][(y + z) % 3][t | (x == z)] += dp[i][x][y][t]) %= MOD; 
				}
			}
		}
	}
	int ans = 0; 
	for (int i = 0; i < 3; i++)
		(ans += dp[n][i][sum][1]) %= MOD; 
	printf("%d\n", ans + (cnt == n - 1));
	return 0; 
}
