#include<bits/stdc++.h>
using namespace std;
#define Re register int
typedef long long ll;

const int N = 1005;
const int p = 998244353;
int n, l1, l2, ans, a[N], b[N], f[N][N][2];
char s1[N], s2[N];

int main()
{
	scanf("%s", s1), l1 = strlen(s1);
	scanf("%s", s2), l2 = strlen(s2);
	for (Re i = 0; i < l1; ++i)
	{
		if (!i) a[i] = 1;
		else if (s1[i] ^ s1[i - 1]) a[i] = a[i - 1] + 1;
		else a[i] = 1;
	}
	for (Re i = 0; i < l2; ++i)
	{
		if (!i) b[i] = 1;
		else if (s2[i] ^ s2[i - 1]) b[i] = b[i - 1] + 1;
		else b[i] = 1;
	}
	for (Re i = 0; i < l1; ++i)
		for (Re j = 0; j < l2; ++j)
		{
			if (s1[i] ^ s2[j]) f[i][j][0] = b[j], f[i][j][1] = a[i];
			if (i)
			{
				if (s1[i] ^ s1[i - 1])
				{
					f[i][j][0] += f[i - 1][j][0];
					if (f[i][j][0] >= p) f[i][j][0] -= p;
				}
				if (s1[i] ^ s2[j])
				{
					f[i][j][0] += f[i - 1][j][1];
					if (f[i][j][0] >= p) f[i][j][0] -= p;
				}
			}
			if (j)
			{
				if (s2[j] ^ s2[j - 1])
				{
					f[i][j][1] += f[i][j - 1][1];
					if (f[i][j][1] >= p) f[i][j][1] -= p;
				}
				if (s1[i] ^ s2[j])
				{
					f[i][j][1] += f[i][j - 1][0];
					if (f[i][j][1] >= p) f[i][j][1] -= p;
				}
			}
			ans += f[i][j][0];
			if (ans >= p) ans -= p;
			ans += f[i][j][1];
			if (ans >= p) ans -= p;
		}
	printf("%d", ans);
	return 0;
}