import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws FileNotFoundException, IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
StringBuffer sb = new StringBuffer();
String line;
while ((line = in.readLine()) != null) {
StringTokenizer st=new StringTokenizer(line,",");
wholeStr=st.nextToken();
str=st.nextToken();
sb.append(getOccurence(0, 0, new StringBuilder()));
sb.append('\n');
}
System.out.print(sb);
}
static String str;
static String wholeStr;
static int getOccurence(int j,int i,StringBuilder string){
if(j==str.length())
return 1;
if(i==wholeStr.length())
return 0;
int counter=0;
if(str.charAt(j)==wholeStr.charAt(i)){
counter=getOccurence(j+1,i+1,string);
}
return getOccurence(j,i+1,string)+counter;
}
}
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws FileNotFoundException, IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
StringBuffer sb = new StringBuffer();
String line;
while ((line = in.readLine()) != null) {
StringTokenizer st=new StringTokenizer(line,",");
wholeStr=st.nextToken();
str=st.nextToken();
sb.append(getOccurence(0, 0, new StringBuilder()));
sb.append('\n');
}
System.out.print(sb);
}
static String str;
static String wholeStr;
static int getOccurence(int j,int i,StringBuilder string){
if(j==str.length())
return 1;
if(i==wholeStr.length())
return 0;
int counter=0;
if(str.charAt(j)==wholeStr.charAt(i)){
counter=getOccurence(j+1,i+1,string);
}
return getOccurence(j,i+1,string)+counter;
}
}