#include <bits/stdc++.h>  

using namespace std;

//#define int long long
#define FOR(i, j, k) for(int i = j; i < (int)k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF (1 << 30)

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); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

int dp[1001][1001];

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s, t;
    cin >> s >> t;

    dp[0][0] = 1;
    rep(i, s.size() + 1) {
    	rep(j, t.size() + 1) {
    		if(i < s.size()) dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
    		if(i < s.size() && j < t.size() && s[i] == t[j]) {
    			dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j]) % MOD;
    		}
    	}
    }
    cout << dp[s.size()][t.size()] << endl;
    return 0;
}