#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5005;
int next[MAXN][26];
char S[MAXN];
char T[MAXN];
int dp[MAXN][MAXN];
int main() {
  scanf("%s %s", S + 1, T + 1);
  int slen = strlen(S + 1);
  int tlen = strlen(T + 1);
  const int MOD = 1000000007;
  for (int j = (int)(0); j <= (int)(tlen); ++j) dp[0][j] = 1;
  for (int i = (int)(0); i <= (int)(slen); ++i) dp[i][0] = 1;
  dp[0][0] = 1;
  for (int i = (int)(1); i <= (int)(slen); ++i)
    for (int j = (int)(1); j <= (int)(tlen); ++j) {
      dp[i][j] = dp[i][j - 1];
      if (S[i] == T[j]) dp[i][j] = (dp[i][j] + dp[i - 1][j - 1]) % MOD;
    }
  long long ans = 0;
  for (int i = (int)(1); i <= (int)(slen); ++i) {
    ans = (ans + dp[i][tlen]) % MOD;
  }
  cout << (ans - slen + MOD) % MOD << endl;
  return 0;
}
