#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
char s[N], t[N];
int s_len, t_len, now, nxt[N];
int dp[2][N], Nxt[26][N];
void kmp_pre(char x[], int m, int nxt[]) {
  int i, j;
  j = nxt[0] = -1;
  i = 0;
  while (i < m) {
    while (-1 != j && x[i] != x[j]) j = nxt[j];
    nxt[++i] = ++j;
  }
}
int main() {
  scanf("%s%s", s, t);
  s_len = strlen(s), t_len = strlen(t);
  if (s_len < t_len) return puts("0"), 0;
  kmp_pre(t, t_len, nxt);
  for (int j = (0); j <= (25); ++j)
    for (int k = (0); k <= (t_len - 1); ++k) {
      int idx = k;
      while (idx != -1 && (j + 'a') != t[idx]) idx = nxt[idx];
      Nxt[j][k] = idx;
    }
  now = 0;
  for (int j = (0); j <= (t_len - 1); ++j) dp[now][j] = -1;
  dp[now][0] = 0;
  for (int i = (0); i <= (s_len - 1); ++i) {
    for (int j = (0); j <= (t_len - 1); ++j) dp[now ^ 1][j] = -1;
    if (s[i] == '?') {
      for (int j = (0); j <= (25); ++j)
        for (int k = (0); k <= (t_len - 1); ++k)
          if (dp[now][k] >= 0) {
            int idx = k, val = dp[now][k];
            if (idx != -1 && (j + 'a') != t[idx]) idx = Nxt[j][idx];
            while (idx != -1 && (j + 'a') != t[idx]) idx = nxt[idx];
            idx++;
            if (idx >= t_len) val++, idx = nxt[idx];
            dp[now ^ 1][idx] = max(dp[now ^ 1][idx], val);
          }
    } else
      for (int k = (0); k <= (t_len - 1); ++k)
        if (dp[now][k] >= 0) {
          int idx = k, val = dp[now][k];
          if (idx != -1 && s[i] != t[idx]) idx = Nxt[s[i] - 'a'][idx];
          while (idx != -1 && s[i] != t[idx]) idx = nxt[idx];
          idx++;
          if (idx >= t_len) val++, idx = nxt[idx];
          dp[now ^ 1][idx] = max(dp[now ^ 1][idx], val);
        }
    now ^= 1;
  }
  int ans = 0;
  for (int k = (0); k <= (t_len); ++k) ans = max(ans, dp[now][k]);
  printf("%d\n", ans);
  return 0;
}
