#include<bits/stdc++.h>
#include<atcoder/modint>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
#define rep(i,l,r) for(int i(l);i<=(r);++i)
#define per(i,r,l) for(int i(r);i>=(l);--i)
#define eb emplace_back
#define File(filename) freopen(filename ".in","r",stdin),freopen(filename ".out","w",stdout)
#ifdef EXODUS
#define Debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define Debug(...) 0
#endif
//=========================================================================================================
// Something about IO
template<typename T>
void read(T &x){
x=0;T flg=1;
char ch=getchar();
while(!isdigit(ch)){if(ch=='-')flg=-1;ch=getchar();}
while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
x*=flg;
}
template<typename T,typename... Args>
void read(T &x,Args &...args){read(x),read(args...);}
//=========================================================================================================
// Define the global variables here.
bool membg=0;
constexpr int N=1e6+7;
char s[N],t[N];
int n,m;
constexpr int mod=998244353,base=131;
struct Hash_t{
pair<int,ull>val;
Hash_t (int val1=0,ull val2=0ull):val(make_pair(val1,val2)){}
Hash_t operator +(int rhs){return Hash_t(val.first+rhs%mod,val.second+rhs);}
Hash_t operator -(Hash_t rhs){return Hash_t((val.first-rhs.val.first+mod)%mod,val.second-rhs.val.second);}
Hash_t operator *(int rhs){return Hash_t((ll)val.first*rhs%mod,val.second*rhs);}
Hash_t operator *(Hash_t rhs){return Hash_t((ll)val.first*rhs.val.first%mod,val.second*rhs.val.second);}
bool operator ==(Hash_t rhs){return val==rhs.val;}
};
Hash_t hshs[N],hsht[N],pwr[N];
bool memed=0;
//=========================================================================================================
// Code here.
Hash_t ask(Hash_t *hsh,int l,int r){
return hsh[r]-hsh[l-1]*pwr[r-l+1];
}
int getlcp(int begs,int begt){
int l=1,r=n,len=0;
while(l<=r){
int mid=(l+r)>>1;
if(begs+mid-1<=n&&begt+mid-1<=m&&ask(hshs,begs,begs+mid-1)==ask(hsht,begt,begt+mid-1))
l=mid+1,len=mid;
else r=mid-1;
}
return len;
}
int getpos(int begs){
int begt=1;
int res=getlcp(begs,begt);
if(begs+res-1==n||begt+res-1==m)return begs+res-1;
begs+=res;begt+=res;
if(begs==n||begt==m)return begs;
begs++,begt++;
res=getlcp(begs,begt);
return begs+res-1;
}
int f[N],g[N],h[N];
int sumf[N],sumg[N],sumh[N];
void solve(){
scanf("%s%s",s+1,t+1);
n=strlen(s+1),m=strlen(t+1);
for(int i=1;i<=n;i++)hshs[i]=hshs[i-1]*base+s[i];
for(int i=1;i<=m;i++)hsht[i]=hsht[i-1]*base+t[i];
int len=max(n,m);
pwr[0]=Hash_t(1,1);
for(int i=1;i<=len;i++)pwr[i]=pwr[i-1]*base;
f[n+1]=g[n+1]=0,h[n+1]=1;
sumf[n+1]=0,sumg[n+1]=0,sumh[n+1]=1;
for(int i=n;i>=1;i--){
int R=getpos(i);
int F=sumf[i+1]-sumf[R+2],G=sumg[i+1]-sumg[R+2],H=sumh[i+1]-sumh[R+2];
f[i]=(F+(ll)2*G+H)%mod,g[i]=(G+H)%mod,h[i]=H;
sumf[i]=sumf[i+1]+f[i],sumg[i]=sumg[i+1]+g[i],sumh[i]=sumh[i+1]+h[i];
}
printf("%d\n",f[1]);
return;
}
//=========================================================================================================
int main(){
Debug("%.3lfMB\n",fabs(&memed-&membg)/1024.0/1024.0);
int timbg=clock();
int T=1;
while(T--)solve();
int timed=clock();
Debug("%.3lfs\n",1.0*(timed-timbg)/CLOCKS_PER_SEC);
fflush(stdout);
return 0;
}