#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;
	bool star = false;
	if(P[0] != '*' && P[0] != S[0])
		return false;
	for(i; i < P.length();i++)
		if(P[i] == '*')
		{
			star = true;
			if(i < P.length())
				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;
		}
		else if(S[k] == P[i])
			k++;
		else
			star = false;	
	i--;
		if((k != S.length() || i != P.length()) && ( P[i] != S[S.length() - 1] || !star))
		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;
}
