#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <cmath>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

const int MAX = 200005;
typedef pair <int, int> PT;
int N, M;
char p[105];
char s[MAX];
int x[MAX][26];

int main()
{
	gets(p);
	gets(s);

	N = strlen(s);
	M = strlen(p);
	memcpy(s + N, s, N);
	memset(x, -1, MAX * 26);

	for (int i = N + N - 1; i >= 0; i--)
	{
		for (int j = 0; j < 26; j++)
		{
			if (s[i] == j + 'a')
			{
				x[i][j] = i;
			}
			else
			{
				x[i][j] = x[i + 1][j];
			}
		}
	}

	int ans = 0;

	for (int i = 0; i < N; i++)
	{
		int j = 0;
		int c = i;

		for (j = 0; j < M; j++)
		{
			if (p[j] == '*')
			{
				continue;
			}

			if (p[j] == s[c])
			{
				++c;
			}
			else
			{
				if (j == 0 || p[j - 1] != '*')
				{
					break;
				}

				c = x[c][p[j] - 'a'];

				if (c == -1 || c >= i + N)
				{
					break;
				}

				++c;
			}
		}

		if (j == M)
		{
			++ans;
		}
	}

	printf("%d\n", ans);

	return 0;
}
