#include <bits/stdc++.h>  

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; --i)
#define repr(i, j) FOR(i, j, 0)
#define INF (1 << 30)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int dp[1001][1001];

int main() {
    string t, b;
    cin >> t >> b;
    int n = t.size(), m = b.size();
    dp[0][0] = 1;
    rep(i, n + 1) rep(j, m + 1) {
        if(i < n) dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
        if(i < n && j < m && t[i] == b[j]) {
            dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j]) % MOD;
        }
    }
    printf("%d\n", dp[n][m]);
    return 0;
}  