#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005, INF = -1000000000;
int n, m, st, en, ans, nxt[MAXN], f[2][MAXN], lst[MAXN][26];
char s[MAXN], t[MAXN];
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  scanf("%s", t + 1);
  m = strlen(t + 1);
  if (n < m) {
    printf("0\n");
    return 0;
  }
  for (int i = 2, j = 0; i <= m; i++) {
    while (j && t[j + 1] != t[i]) j = nxt[j];
    if (t[j + 1] == t[i]) j++;
    nxt[i] = j;
  }
  for (int i = (0); i <= (m); i++)
    for (int j = (0); j <= (25); j++) {
      int k = i;
      while (k && t[k + 1] != j + 'a') k = nxt[k];
      if (t[k + 1] == j + 'a') k++;
      lst[i][j] = k;
    }
  for (int j = (1); j <= (m); j++) f[0][j] = INF;
  for (int i = (0); i <= (n - 1); i++) {
    int ii = i & 1, iii = ii ^ 1;
    for (int j = (0); j <= (m); j++) f[iii][j] = INF;
    for (int j = (0); j <= (m); j++)
      if (f[ii][j] > INF) {
        if (s[i + 1] == '?')
          st = 0, en = 25;
        else
          st = en = s[i + 1] - 'a';
        for (int k = (st); k <= (en); k++)
          f[iii][lst[j][k]] =
              max(f[iii][lst[j][k]], f[ii][j] + (lst[j][k] == m));
      }
  }
  for (int j = (0); j <= (m); j++) ans = max(ans, f[n & 1][j]);
  printf("%d\n", ans);
  return 0;
}
