#include <bits/stdc++.h>
#define X first
#define Y second

using namespace std;
typedef long long llint;

const int maxn = 1005;
const int base = 31337;
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
const int logo = 20;
const int off = 1 << logo;
const int treesiz = off << 1;

int n, m;
char a[maxn], b[maxn];
int dp[maxn][maxn][2][2][2];

int f(int x, int y, int wh, bool flag1, bool flag2) {
	int &ret = dp[x][y][wh][flag1][flag2];
	if (ret != -1) return ret;
	
	ret = (flag1 && flag2);
	char las;
	if (wh == 0) las = a[x - 1];
	else las = b[y - 1];
	
	if (x < n && a[x] != las) ret += f(x + 1, y, 0, true, flag2), ret %= mod;
	if (y < m && b[y] != las) ret += f(x, y + 1, 1, flag1, true), ret %= mod;
	return ret;
}

int main() {
	scanf("%s%s", a, b);
	n = strlen(a);
	m = strlen(b);
	
	memset(dp, -1, sizeof dp);
	int sol = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			sol += f(i + 1, j, 0, true, false);
			sol %= mod;
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			sol += f(i, j + 1, 1, false, true);
			sol %= mod;
		}
	}
	printf("%d\n", sol);
	return 0;
}
