#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
using namespace std;

typedef long long ll;
const ll LINF = (1ll << 62) - 1;
const int INF = (1 << 30) - 1;

const int NR = 1000 + 10;
const int P = 998244353;

ll l1, l2, las1[NR], las2[NR], f[NR][NR][2], ans = 0;
char s1[NR], s2[NR];

int main()
{
	std::ios::sync_with_stdio(0);

	scanf("%s", s1 + 1);
	scanf("%s", s2 + 1);
	l1 = strlen(s1 + 1), l2 = strlen(s2 + 1);

	las1[1] = las2[1] = 1;	
	for (int i = 2; i <= l1; i++) {
		las1[i] = las1[i - 1];
		if (s1[i] == s1[i - 1]) las1[i] = i;
	}
	for (int i = 2; i <= l2; i++) {
		las2[i] = las2[i - 1];
		if (s2[i] == s2[i - 1]) las2[i] = i;
	}

	for (int i = 1; i <= l1; i++) {
		for (int j = 1; j <= l2; j++) {
			if (s1[i] != s2[j]) {
				f[i][j][0] = (f[i][j][0] + j - las2[j] + 1) % P;
				f[i][j][1] = (f[i][j][1] + i - las1[i] + 1) % P;
			}
			if (s1[i + 1] != s1[i]) f[i + 1][j][0] = (f[i + 1][j][0] + f[i][j][0]) % P;
			if (s2[j + 1] != s2[j]) f[i][j + 1][1] = (f[i][j + 1][1] + f[i][j][1]) % P;
			if (s1[i + 1] != s2[j]) f[i + 1][j][0] = (f[i + 1][j][0] + f[i][j][1]) % P;
			if (s2[j + 1] != s1[i]) f[i][j + 1][1] = (f[i][j + 1][1] + f[i][j][0]) % P;
			ans = (ans + f[i][j][0] + f[i][j][1]) % P;
		}
	}

	printf("%d\n", ans);

	return 0;
}