#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<cctype>
#include<cstdlib>
#include<vector>
#include<algorithm>
#include<queue>
#define fs(i,x,y) for(int i=(x),_=(y);i<=_;++i)
#define fn(i,x,y) for(int i=(x),_=(y);i>=_;--i)
#define tor(i,v,x) for(int i=head[x],v=to[i];i;i=nxt[i],v=to[i])
#define ls(x) ch[x][0]
#define rs(x) ch[x][1]
#define mpi(x,y) make_pair(x,y)
#define pi pair<int,int>
//#define int ll
#define DEBUG printf("%s %d\n",__FUNCTION__,__LINE__)
using namespace std;
typedef long long ll;
typedef double db;
template<typename T>
void read(T &x){
	x=0;char ch=getchar();bool f=0;
	while(ch<'0'||ch>'9'){
		if(ch=='-')f=1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
	x=f?-x:x;
}

const int N=1e3+7,P=998244353;
int n,m;
char s[N],t[N];
int f[N][N][2][4];

void add(int &x,int y){x+=y;if(x>=P)x-=P;}

signed main(){
	scanf("%s",s+1);scanf("%s",t+1);
	n=strlen(s+1);m=strlen(t+1);
	fs(i,0,n)fs(j,0,m){
		if(i<n)add(f[i+1][j][0][1],1);
		if(j<m)add(f[i][j+1][1][2],1);//需要标记最后取哪个
		//而且都取了的方案才是合法
		fs(st,0,3){
			if(i<n&&s[i]!=s[i+1])add(f[i+1][j][0][st|1],f[i][j][0][st]);
			if(j<m&&s[i]!=t[j+1])add(f[i][j+1][1][st|2],f[i][j][0][st]);
			if(i<n&&t[j]!=s[i+1])add(f[i+1][j][0][st|1],f[i][j][1][st]);
			if(j<m&&t[j]!=t[j+1])add(f[i][j+1][1][st|2],f[i][j][1][st]);
		}
	}
	int ans=0;
	fs(i,1,n)fs(j,1,m)add(ans,f[i][j][0][3]),add(ans,f[i][j][1][3]);
	printf("%d\n",ans);
	return 0;
}