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

long long dp[1001][1001] = {0};

int main() {

    string t,b;

    cin >> t >> b;

    int s1 = t.size(),s2 = b.size();

    dp[0][0] = 1;

    for(int i=0;i<s1;i++){
        dp[i+1][s2] += dp[i][s2];
        dp[i+1][s2] %= 1000000007;
        for(int j=0;j<s2;j++){
            if(t[i] == b[j]){
                dp[i+1][j+1] += dp[i][j];
                dp[i+1][j+1] %= 1000000007;
            }
            dp[i+1][j] += dp[i][j];
        }
        /*for(int y=0;y<=s2;y++){
            for(int x=0;x<=s1;x++){
                cout << dp[x][y] << " ";
            }
            cout << endl;
        }
        cout << endl;*/
    }
/*
    for(int j=0;j<s2;j++){
        for(int i=0;i<s1;i++){
            if(b[j] == t[i]) {
                dp[i + 1][j + 1] = dp[i][j];
            }
            dp[i+1][j] = dp[i][j];

        }
    }
*/
/*
    for(int y=0;y<=s2;y++){
        for(int x=0;x<=s1;x++){
            cout << dp[x][y] << " ";
        }
        cout << endl;
    }
*/




    /*for(int i=0;i<=s1;i++){
        for(int j=0;j<=s2;j++){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }*/

    cout << dp[s1][s2] << endl;
    return 0;
}