#include <stdio.h>
#include <string>
#include <iostream>

bool find(std::string S, std::string P);
std::string cycle(std::string S);

int main(int argc, char* argv[])
{
	std::string P;
	std::cin >> P;
	std::string S;
	std::cin >> S;
	int q = 0;
		if(find(S,P))
		q++;

	for(int i = 1; i < S.length(); i++)
	{
		S = cycle(S);
		if(find(S,P))
			q++;
	}
	printf("%d\n", q);
	system("pause");
	return 0;
}

bool find(std::string S,std::string P)
{
	int i = 0;
	int k = 0;
	while(P[i] == '*')
		i++;
	for(i; i < P.length();i++)
		if(P[i] != '*')
		{
			for(int p = k; p < S.length(); p++)
			{
				k++;
				if(S[k] == P[i])
					break;
				}
			if(k == S.length() -1 && S[k] != P[i])
				return false;
		}
		i--;
	if(k != S.length() - 1 && P[i] != '*' && P[i] != S[S.length() - 1])
		return false;
	return true;
}

std::string cycle(std::string S)
{
	std::string P;
	P = S;
	P[0] = S[S.length() - 1];
	for(int i = 0; i < S.length() -1; i++)
		P[i+1] = S[i];
	return P;
}
