#include<bits/stdc++.h>
using namespace std;
int main()
{
char s[256],b[256],a[256];
int i,j=0,x=0,q=0,n=0;
gets(s);
gets(a);
for(i=0;i<strlen(s);i++){
if(s[i]!=' '){
b[j]=s[i];
j++;
if(s[i+1]==' '||s[i+1]=='.'){
b[j]='\0';
n++;
if(strcmp(a,b)==0){
x=1;
q++;
break;
}
j=0;
q++;
}
}
}
if(x==1)
cout<<q;
else
cout<<strlen(s)-n;
return 0;
}
/**************************************************************
Problem: 1012
User: houshanglin
Language: C++
Result: Accepted
Time:7 ms
Memory:2076 kb
****************************************************************/