// Problem: E. Chaotic Merge
// Contest: Codeforces - Educational Codeforces Round 106 (Rated for Div. 2)
// URL: http://codeforces.com/contest/1499/problem/E
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>
using namespace std;

#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
// #define int long 
#define endl '\n'
#define vi vector<int>
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define fill(a,b) memset(a, b, sizeof(a))
#define setbits(x) __builtin_popcountll(x)

const int mod = 998244353;
int dx[]={0,1,1,1,0,-1,-1,-1};
int dy[]={1,1,0,-1,-1,-1,0,1};

// <--------------------Code Begins Here-------------------->
string s0, s1;
int n, m, dp[1005][1005][4][2][2];

int call(int i, int j, int f, int f1, int f2) {
	if(f == 3)return 1;
	if(i == n && j == m)return 0;
	int &ans = dp[i][j][f][f1][f2];
	if(ans != -1)return ans;
	ans = 0;
	int c;
	if(f2 == 0)c = 26;
	else {
		if(f1)c = (s1[j - 1] - 'a');
		else c = (s0[i - 1] - 'a');
	}
	if(f == 0) {
		if(i < n && (s0[i] - 'a') != c) {
			ans += call(i + 1, j, 0, 0, 1);
			ans %= mod;
			ans += call(i + 1, j, 1, 0, 1);
			ans %= mod;
		}
		if(j < m && (s1[j] - 'a') != c) {
			ans += call(i, j + 1, 0, 1, 1);
			ans %= mod;
			ans += call(i, j + 1, 2, 1, 1);
			ans %= mod;
		}
	}
	else if(f == 1) {
		if(j < m && (s1[j] - 'a') != c) {
			ans += call(i, j + 1, 1, 1, 1);
			ans %= mod;
			ans += call(i, j + 1, 3, 1, 1);
			ans %= mod;
		}
	}
	else if(f == 2) {
		if(i < n && (s0[i] - 'a') != c) {
			ans += call(i + 1, j, 2, 0, 1);
			ans %= mod;
			ans += call(i + 1, j, 3, 0, 1);
			ans %= mod;
		}
	}
	return ans;
}

int32_t main() {
    SPEED;
    int t = 1;
    // cin>>t;
    while(t--) {
    	cin>>s0>>s1;
    	n = s0.size();
    	m = s1.size();
    	fill(dp, -1);
    	int ans = 0;
    	for(int i = 0; i < n; ++i) {
    		for(int j = 0; j < m; ++j) {
    			ans += call(i, j, 0, 0, 0);
    			ans %= mod;
    		}
    	}
    	cout<<ans;
    }
    return 0;
}