#include #include #include using namespace std; #include using mint = atcoder::modint998244353; constexpr int md = mint::mod(); int main() { cin.tie(nullptr), ios::sync_with_stdio(false); string S, T; cin >> S >> T; const int n = T.size(); vector dp(n + 1); dp[0] = 1; for (auto c : S) { for (int i = n - 1; i >= 0; --i) { if (T[i] == c) { dp[i + 1] += dp[i]; if (dp[i + 1] >= md) dp[i + 1] -= md; } } } cout << (mint(2).pow(S.size() - T.size()) * dp.back()).val() << '\n'; }