import java.util.*;
import java.io.*;

public class Main implements Runnable {

	Scanner in;
	PrintWriter out;

	boolean find(StringBuilder sb, StringBuilder patternSubs, int curLinePos) {
		int matchCnt = 0;
		for (int i = 0; i < patternSubs.length(); i++) {
			if (curLinePos + i < sb.length()
					&& patternSubs.charAt(i) == sb.charAt(curLinePos + i)) {
				matchCnt++;
			} else {
				break;
			}
		}
		return matchCnt == patternSubs.length();
	}

	boolean check(StringBuilder sb, int start, int len, String pattern) {
		int curPatternPos = 0;
		int end = start + len - 1;
		int curLinePos = start;
		boolean patternEnded = false;
		boolean canSkip = false;
		while (true) {
			canSkip = false;
			while (curPatternPos < pattern.length()
					&& pattern.charAt(curPatternPos) == '*') {
				curPatternPos++;
				canSkip = true;
			}
			if (curPatternPos == pattern.length()) {
				return true;
			}
			if (pattern.charAt(curPatternPos) != '*') {
				StringBuilder patternSubs = new StringBuilder();
				while (curPatternPos < pattern.length()
						&& pattern.charAt(curPatternPos) != '*') {
					patternSubs.append(pattern.charAt(curPatternPos));
					curPatternPos++;
				}

				if (curPatternPos == pattern.length()) {
					patternEnded = true;
				}

				if (patternEnded && canSkip) {
					for (int backI = end-patternSubs.length()+1; backI >= curLinePos; backI--) {
						if (!find(sb, patternSubs, backI)) {

						} else {
							if (backI+patternSubs.length()-1<end){
								return false;
							}else{
								return true;
							}
						}
					}
					return false;
				} else if (!patternEnded && canSkip) {
					while (true) {
						int matchCnt = 0;
						for (int i = 0; i < patternSubs.length(); i++) {
							if (curLinePos + i < sb.length()
									&& patternSubs.charAt(i) == sb
											.charAt(curLinePos + i)) {
								matchCnt++;
							} else {
								break;
							}
						}
						if (matchCnt != patternSubs.length()) {
							if (curLinePos + patternSubs.length() - 1 == end) {
								return false;
							}
							curLinePos++;
						} else {
							curLinePos += matchCnt;
							break;
						}
					}
				} else if (patternEnded && !canSkip) {
					int matchCnt = 0;
					for (int i = 0; i < patternSubs.length(); i++) {
						if (curLinePos + i < sb.length()
								&& patternSubs.charAt(i) == sb
										.charAt(curLinePos + i)) {
							matchCnt++;
						} else {
							break;
						}
					}
					if (matchCnt != patternSubs.length()) {
						return false;
					} else {
						curLinePos += matchCnt;
						if (curLinePos==end+1){
							return true;
						}
						break;
					}
				}

			}
		}
		return false;
	}

	void solve() {
		String template = in.nextLine();
		String st = in.nextLine();
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < st.length(); i++) {
			sb.append(st.charAt(i));
		}
		for (int i = 0; i < st.length(); i++) {
			sb.append(st.charAt(i));
		}
		int cnt = 0;
		for (int i = 0; i < st.length(); i++) {
			if (check(sb, i, st.length(), template)) {
				cnt++;
			}
		}
		out.println(cnt);
	}

	public void run() {
		in = new Scanner(System.in);
		out = new PrintWriter(System.out);
		try {
			solve();
		} finally {
			out.close();
		}
	}

	public static void main(String args[]) {
		new Main().run();
	}

}
