#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<random>
#include<functional>
#include<utility>

#define rep(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define P pair<int, int>
#define PLI pair<ll, int>

using namespace std;

typedef long long ll;


const int MOD = 1e9 + 7;

string t, b;
int dp[1005][1005] = {};
int main() {
	cin >> t >> b;
	dp[0][0] = 1;
	rep(i, t.size()) {
		rep(j, b.size()) {
			if (t[i] == b[j]) dp[i + 1][j + 1] += dp[i][j];
			dp[i + 1][j] += dp[i][j];
			dp[i + 1][j + 1] %= MOD;
			dp[i + 1][j] %= MOD;
		}
	}

	int ans = 0;
	rep(i, t.size()+1) {
		ans += dp[i][b.size()];
		ans %= MOD;
	}

	cout << ans << endl;

	return 0;
}

