#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T read() {
  T x = 0, w = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') w = -w;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  return x * w;
}
template <class T>
inline T read(T& x) {
  return x = read<T>();
}
const int N = 1e5 + 10;
char s[N], t[N];
int fa[N], dp[N];
int main() {
  scanf("%s", s + 1);
  int n = strlen(s + 1);
  scanf("%s", t + 1);
  int m = strlen(t + 1);
  for (int i = 2; i <= m; ++i) {
    int j = fa[i - 1];
    while (j and t[j + 1] != t[i]) j = fa[j];
    fa[i] = j + (t[j + 1] == t[i]);
  }
  fill(dp, dp + m + 1, -1), dp[0] = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = m; j >= 0; --j)
      if (dp[j] != -1) {
        if (j > 0) dp[fa[j]] = max(dp[fa[j]], dp[j]);
        if (j < m and (s[i] == '?' or s[i] == t[j + 1])) dp[j + 1] = dp[j];
        if (j > 0) dp[j] = -1;
      }
    if (dp[m] != -1) ++dp[m];
  }
  printf("%d\n", *max_element(dp, dp + m + 1));
  return 0;
}
