#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define NUM 1000000007
string ward,magic;
vector<vector<int> > dp;
int solve(int,int);
int main(){
    cin>>ward>>magic;
    dp.resize(ward.size());
    for(int i=0;i<ward.size();++i){
        dp[i].resize(magic.size());
        for(int j=0;j<magic.size();++j){
            dp[i][j]=-1;
        }
    }
    cout<<solve(0,0)<<endl;
    return 0;
}

int solve(int place,int use){
    if(use==magic.size()){
        return 1;
    }
    if(place==ward.size()){
        return 0;
    }
    if(dp[place][use]>=0){
        return dp[place][use];
    }
    
    
    int res = 0;
    res=solve(place+1,use);
    if(ward[place]==magic[use]){
        res+=solve(place+1,use+1);
    }
    res%=NUM;
    return dp[place][use]=res;
}