//CountString
//cho 1 cau, 1 xau ki tu. dem xem trong cau co bao nhieu xau nhu the
#include <iostream>
#include <stdio.h>
#include <conio.h>
using namespace std;
int main()
{
int n;
char subString[6];
char sentence[500];
freopen("Testcase.txt", "r", stdin);
/*for(int testcase = 1; testcase <= 10; testcase++)
{*/
int count = 0;
cin >> n;
gets(subString);
gets(sentence);
int a = 0, b = 0;
while(subString[a] != '\0')
a++;
while(sentence[b] != '\0')
b++;
for(int i=b-1;i>=0;i--)
{
for(int j=a-1;j>=0;j--)
{
if(sentence[i]==subString[j])
{
if(j==0)
count++;
i--;
}
}
}
/*cout << "#" << testcase << " " << count << endl;*/
cout << count;
/*}*/
getch();
return 0;
}