#include <bits/stdc++.h>
using namespace std;
const int NR = 1e5 + 5;
const int MR = 1e5 + 5;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
inline int read() {
  int x = 0;
  int bei = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') bei = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * bei;
}
char a[NR], b[MR];
int bord[NR];
int getnxt(int x, char c) {
  if (b[x + 1] == c) return x + 1;
  return x ? getnxt(bord[x], c) : 0;
}
int nxt[NR][29];
int dp[2][MR];
int ans;
int main() {
  scanf("%s", a + 1);
  scanf("%s", b + 1);
  int n = strlen(a + 1), m = strlen(b + 1);
  for (int i = 2; i <= m; ++i) bord[i] = getnxt(bord[i - 1], b[i]);
  for (int i = 1; i <= 26; ++i) {
    nxt[0][i] = getnxt(0, i + 'a' - 1);
  }
  for (int i = 1; i < m; ++i)
    for (int j = 1; j <= 26; ++j) {
      if (b[i + 1] - 'a' + 1 == j)
        nxt[i][j] = i + 1;
      else
        nxt[i][j] = nxt[bord[i]][j];
    }
  int p = 0, q = 1;
  memset(dp, 0xc0, sizeof(dp));
  dp[q][0] = 0;
  for (int i = 0; i < n; ++i) {
    swap(p, q);
    for (int j = 0; j <= m; ++j) dp[q][j] = -INF;
    for (int j = 0; j < m; ++j) {
      if (a[i + 1] != '?')
        dp[q][nxt[j][a[i + 1] - 'a' + 1]] =
            max(dp[q][nxt[j][a[i + 1] - 'a' + 1]], dp[p][j]);
      else {
        for (int k = 1; k <= 26; ++k)
          dp[q][nxt[j][k]] = max(dp[q][nxt[j][k]], dp[p][j]);
      }
    }
    dp[q][bord[m]] = max(dp[q][bord[m]], dp[q][m] + 1);
  }
  dp[q][bord[m]] = max(dp[q][bord[m]], dp[q][m] + 1);
  for (int i = 0; i < m; ++i) ans = max(ans, dp[q][i]);
  printf("%d", ans);
  return 0;
}
