#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b;
  cin >> a >> b;
  long long m = 1000000007;
  vector<long long> r(a.size() + 1);
  for (size_t i = 0; i < b.size(); i++)
    for (int j = a.size() - 1; j >= 0; j--) {
      if (a[j] == b[i]) {
        r[j + 1] += r[j] + 1;
        r[j + 1] %= m;
      }
    }
  long long R = 0;
  for (size_t i = 0; i < r.size(); ++i) {
    R += r[i];
    R %= m;
  }
  cout << R << endl;
  return 0;
}
