#include <cstdio>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;

namespace thecold
{
	typedef long long ll;

	inline ll read()
	{
		ll res = 0; bool flag = false;
		char c = getchar();
		while(!isdigit(c))
			flag = (c == '-') , c = getchar();
		while(isdigit(c))
			res = res * 10 + (c ^ 48) , c = getchar();
		return !flag ? res : -res;
	}

	const int Max_n = 1e3 + 5;
	const int jzp = 998244353;

	int n , m , f[Max_n][Max_n][2];

	inline void MAX(int &x , const int y)
	{
		if(x < y) x = y;
	}

	inline void MIN(int &x , const int y)
	{
		if(x > y) x = y;
	}
	
	inline void ADD(int &x , const int y)
	{
		x += y; if(x >= jzp) x -= jzp;
	}
	
	inline int add(const int x , const int y)
	{
		int ret = x + y;
		if(ret >= jzp) ret -= jzp;
		return ret;
	}
	
	char a[Max_n] , b[Max_n];

	inline void main()
	{
		scanf("%s" , a + 1); scanf("%s" , b + 1);
		n = strlen(a + 1) , m = strlen(b + 1);
		for(int i = 1 ; i <= n ; ++ i)
			for(int j = 1 ; j <= m ; ++ j)
				f[i][j - 1][0] = f[i - 1][j][1] = 1;
		for(int i = 0 ; i <= n ; ++ i)
			for(int j = 0 ; j <= m ; ++ j)
			{
				if(i > 0 && a[i] != a[i - 1])
					ADD(f[i][j][0] , f[i - 1][j][0]);
				if(i > 0 && a[i] != b[j])
					ADD(f[i][j][0] , f[i - 1][j][1]);
				if(j > 0 && b[j] != b[j - 1])
					ADD(f[i][j][1] , f[i][j - 1][1]);
				if(j > 0 && b[j] != a[i])
					ADD(f[i][j][1] , f[i][j - 1][0]);
			}
		int cnt = 0;
		for(int i = 1 ; i <= n ; ++ i)
		{
			int ct = 1;
			for(int j = i + 1 ; j <= n ; ++ j)
				if(a[j] != a[j - 1]) ++ ct;
				else break;
			ADD(cnt , 1ll * ct * m % jzp);
		}
		for(int i = 1 ; i <= m ; ++ i)
		{
			int ct = 1;
			for(int j = i + 1 ; j <= m ; ++ j)
				if(b[j] != b[j - 1]) ++ ct;
				else break;
			ADD(cnt , 1ll * ct * n % jzp);
		}
		int ans = 0;
		for(int i = 0 ; i <= n ; ++ i)
			for(int j = 0 ; j <= m ; ++ j)
				ADD(ans , add(f[i][j][0] , f[i][j][1]));
		printf("%d\n" , add(ans , jzp - cnt));
	}
}

int main()
{
	thecold::main();
	return 0;
}
