#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i,n=0,j=0;
	bool z=1;
	char a[256],s[256],d[256];
	gets(a);
	gets(d);
	for(i=0;i<strlen(a);i++){
		if(a[i]!=' '){
			s[n]=a[i];
			n++;
			if(a[i+1]==' '||a[i+1]=='.'){
				s[n]='\0';
				j++;
				if(strcmp(s,d)==0){
					z=0;
					cout<<j;
					break;
				}
				n=0;
			}
		}	
	}
	if(z==1){
		cout<<strlen(a)-j;
	}
	return 0;
}

/**************************************************************
	Problem: 1012
	User: zzz
	Language: C++
	Result: Accepted
	Time:9 ms
	Memory:2076 kb
****************************************************************/