#include <bits/stdc++.h>
const int MAX = 1e5 + 10;
using namespace std;
char x[MAX], y[MAX];
int func[MAX][26], f[MAX], xlen, ylen;
int dp[2][MAX];
int main() {
  scanf("%s %s", x, y);
  xlen = strlen(x);
  ylen = strlen(y);
  int k = 0;
  f[0] = 0;
  if (xlen < ylen) {
    printf("0\n");
    return 0;
  }
  for (int i = 1; i < ylen; ++i) {
    while (k > 0 && y[i] != y[k]) k = f[k - 1];
    if (y[i] == y[k]) k++;
    f[i] = k;
  }
  for (int i = 0; i < ylen; ++i) {
    for (int c = 'a'; c <= 'z'; ++c) {
      k = i;
      while (k > 0 && y[k] != c) k = f[k - 1];
      if (y[k] == c) k++;
      func[i][c - 'a'] = k;
    }
  }
  for (int i = xlen - 1; i >= 0; i--) {
    for (int j = 0; j < ylen; j++) {
      dp[(i & 1)][j] = 0;
      if (x[i] == '?') {
        for (int k = 0; k < 26; k++) {
          int nsuff = func[j][k];
          if (nsuff == ylen) {
            nsuff = f[ylen - 1];
            dp[(i & 1)][j] = max(dp[(i & 1)][j], 1 + dp[!(i & 1)][nsuff]);
          } else
            dp[(i & 1)][j] = max(dp[(i & 1)][j], dp[!(i & 1)][nsuff]);
        }
      } else {
        int nsuff = func[j][x[i] - 'a'];
        if (nsuff == ylen) {
          nsuff = f[ylen - 1];
          dp[(i & 1)][j] = 1 + dp[!(i & 1)][nsuff];
        } else
          dp[(i & 1)][j] = dp[!(i & 1)][nsuff];
      }
    }
  }
  printf("%d\n", dp[0][0]);
  return 0;
}
