#include <bits/stdc++.h>
char A[100005], B[100005];
int dp[10000005 << 1], nxt[100005];
int F[100005][30];
void Init(char *A, int len, int *nxt) {
  nxt[0] = nxt[1] = 0;
  for (int i = 1, j = 0; i < len; i++) {
    while (j && A[i] != A[j]) j = nxt[j];
    if (A[i] == A[j]) j++;
    nxt[i + 1] = j;
  }
}
void check_max(int &x, int y) {
  if (x < y) x = y;
}
int main() {
  scanf("%s%s", A, B);
  int sza = strlen(A), szb = strlen(B);
  Init(B, szb, nxt);
  for (int i = 0; i < 26; i++) F[0][i] = (B[0] == 'a' + i);
  for (int i = 1; i < szb; i++) {
    for (int j = 0; j < 26; j++) {
      if (B[i] == 'a' + j)
        F[i][j] = i + 1;
      else
        F[i][j] = F[nxt[i]][j];
    }
  }
  memset(dp, -1, sizeof(dp));
  dp[(0) * (szb + 5) + 0] = 0;
  for (int i = 0; i < sza; i++) {
    for (int j = 0; j < szb; j++) {
      if (~dp[(i) * (szb + 5) + j]) {
        if (A[i] != '?') {
          int K = F[j][A[i] - 'a'];
          if (K == szb)
            check_max(dp[(i + 1) * (szb + 5) + nxt[K]],
                      dp[(i) * (szb + 5) + j] + 1);
          else {
            check_max(dp[(i + 1) * (szb + 5) + K], dp[(i) * (szb + 5) + j]);
          }
        } else {
          for (int k = 0; k < 26; k++) {
            int K = F[j][k];
            if (K == szb)
              check_max(dp[(i + 1) * (szb + 5) + nxt[K]],
                        dp[(i) * (szb + 5) + j] + 1);
            else
              check_max(dp[(i + 1) * (szb + 5) + K], dp[(i) * (szb + 5) + j]);
          }
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < szb; i++) check_max(ans, dp[(sza) * (szb + 5) + i]);
  printf("%d\n", ans);
  return 0;
}
