#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
using namespace std;

const int MOD = 1000000007;
int dp[1010][1010];

int main() {
  string s, t; cin >> s >> t;
  int N = s.length(), M = t.length();

  dp[0][0] = 1;
  for(int i=0; i<N; i++) {
    for(int j=0; j<M; j++) {
      (dp[i+1][j] += dp[i][j]) %= MOD;
      if(s[i] == t[j]) {
        (dp[i+1][j+1] += dp[i][j]) %= MOD;
      }
    }
  }

  int ans = 0;
  for(int i=0; i<=N; i++) {
    (ans += dp[i][M]) %= MOD;
  }
  cout << ans << endl;
  return 0;
}

