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

long long int dp[1001][1001];
const long long int mod(1e9 + 7);
int main() {
	string t, b; cin >> t >> b;
	for (int i = 0; i < 1001; ++i) {
		for (int j = 0; j < 1001; ++j) {
			dp[i][j] = 0;
		}
	}
	dp[0][0] = 1;
	for (int i = 0; i < t.size(); ++i) {
		for (int j = 0; j <= b.size(); ++j) {
			dp[i + 1][j] += dp[i][j];
			dp[i + 1][j] %= mod;
			if (j != b.size()&&t[i]==b[j]) {
				dp[i + 1][j + 1] += dp[i][j];
				dp[i + 1][j+1] %= mod;
			}
		}
	}
	cout << (dp[t.size()][b.size()] % mod) << endl;
	return 0;
}