#include <bits/stdc++.h>

using namespace std;

#define mem(a,b) memset(a,b,sizeof(a))
#define FOR(i,j,k) for(int i=j;i<=k;i++)
#define read        freopen("in.txt", "r", stdin)
#define write       freopen("out.txt", "w", stdout)
#define pf          printf
#define sf(n)       scanf("%d", &n)
#define sff(a,b)    scanf("%d %d", &a, &b)
#define PB push_back
#define F first
#define S second
#define MP make_pair

typedef long long ll;
typedef pair<int,int> pii;

const int M = 998244353 ;
const int MAX = (1e3) + 10;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, m, dp[MAX][MAX][4][2];
string A, B;

int add(int x,int y) {
    int r = x + y;
    return (r >= M) ? (r - M) : r;
}

int rec(int x,int y,int s,int t) {
    // cout << x << " " << y << ' ' << s << " " << t << endl;
    int &temp = dp[x][y][s][t];
    if(temp != -1) return temp;

    temp = s == 3 ? 1 : 0;
    char c = t == 0 ? A[x - 1] : B[y - 1];

    if(x < n && A[x] != c) {
        temp = add(temp, rec(x + 1, y, (s | 1), 0));
    }
    if(y < m && B[y] != c) {
        temp = add(temp, rec(x, y + 1, (s | 2), 1));
    }
    return temp;
}

void solve() {
    cin >> A >> B;
    n = A.size();
    m = B.size();

    int c = 0;
    mem(dp, -1);
    FOR(i,0,n-1) {
        FOR(j,0,m-1) {
            c = add(c, rec(i + 1, j, 1, 0));
            c = add(c, rec(i, j + 1, 2, 1));
        }
    }
    cout << c << endl;
}

int main() {
    ios::sync_with_stdio(false);
    //read;
    //write;
    solve();
    return 0;
}

