Code:

int fun(string T, string S){

```
int m = T.size();
int n = S.size();
if(m>n) return 0;
int dp[m+1][n+1];
for (int i = 1; i <= n; i++)
dp[0][i] = 1;
for (int j = 0; j <= m; j++)
dp[j][0] = 0;
for(int i=1;i<=m;++i){
for(int j=1;j<=n;++j){
if(T[i-1]!=S[j-1]){
dp[i][j] = dp[i-1][j];
}
else{
dp[i][j] = dp[i-1][j] + dp[i-1][j-1];
}
}
}
```

return dp[m][n];

}