#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long exp(long long x, long long n, long long mod) {
  long long result = 1;
  while (n) {
    if (n & 1) result = (result * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return result;
}
const long long M = 1e9 + 7;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s, t;
  cin >> s >> t;
  int n1 = s.length(), n2 = t.length();
  long long dp[n1 + 1][n2 + 1];
  memset(dp, 0LL, sizeof(dp));
  for (int i = n1 - 1; i >= 0; i--) {
    for (int j = n2 - 1; j >= 0; j--) {
      dp[i][j] = dp[i][j + 1];
      if (s[i] == t[j])
        dp[i][j] = (dp[i][j] + (dp[i + 1][j + 1] + 1LL) % M) % M;
    }
  }
  long long ans = 0;
  for (int i = 0; i < n1; i++) ans = (ans + dp[i][0]) % M;
  cout << ans << "\n";
  return 0;
}
