#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;

#define MOD 1000000007

string t, b;
int dp[1001][1001];

int rec(int n, int m) {
    if(m == b.size()) return 1;
    if(n >= t.size() || m >= b.size()) return 0;
    if(~dp[n][m]) return dp[n][m];

    int ret = 0;
    for(int i = n; i < t.size(); i++) {
        if(t[i] == b[m]) {
            ret = (ret + rec(i + 1, m + 1)) % MOD;
        }
    }
    return dp[n][m] = ret;
}

int main() {

    cin >> t >> b;
    memset(dp, -1, sizeof(dp));
    cout << rec(0, 0) << endl;
}