#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
int main(){
    string s,t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    vector<vector<ll>> dp(n + 1, vector<ll>(m + 1, 0));
    dp[0][0] = 1;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < m; ++j){
            if(!dp[i][j])continue;

            dp[i+1][j] += dp[i][j];
            dp[i+1][j] %= MOD;
            if(s[i] == t[j]){
                dp[i+1][j+1] += dp[i][j];
                dp[i+1][j+1] %= MOD;
            }
        }
        dp[i+1][m] += dp[i][m];
        dp[i+1][m] %= MOD;
    }
    cout << dp[n][m] % MOD << endl;
}

