#include <bits/stdc++.h>
using namespace std;
int t, a, b, Ne[100005], now, la, ans;
int La[100005][26];
char A[100005], B[100005];
int main() {
  scanf("%s%s", A + 1, B + 1);
  a = strlen(A + 1), b = strlen(B + 1);
  int Dp[a + 1][b + 1];
  memset(Ne, 0, sizeof(Ne));
  memset(Dp, 0, sizeof(Dp));
  now = 1, la = 0;
  while (now <= b) {
    if (la == 0 || B[now] == B[la])
      ++la, ++now, Ne[now] = la;
    else
      la = Ne[la];
  }
  memset(Dp, -1, sizeof(Dp));
  if (b == 1) {
    ans = 0;
    for (int i = 1; i <= a; ++i) ans += A[i] == '?' || A[i] == B[1];
    printf("%d\n", ans);
    return 0;
  }
  for (int i = 1; i <= b; ++i) {
    memcpy(La[i], La[Ne[i]], sizeof(La[i]));
    La[i][B[i] - 'a'] = i;
  }
  if (A[1] == '?')
    Dp[1][1] = Dp[1][0] = 0;
  else
    Dp[1][A[1] == B[1]] = 0;
  for (int p = 1; p < a; ++p) {
    if (A[p + 1] != '?') {
      int k = A[p + 1] - 'a';
      for (int i = b - 2; ~i; --i) {
        if (Dp[p][i] == -1) continue;
        now = La[i + 1][k];
        Dp[p + 1][now] = max(Dp[p][i], Dp[p + 1][now]);
      }
      if (Dp[p][b - 1] == -1) continue;
      now = La[b][k];
      if (now == b) {
        now = Ne[now + 1] - 1;
        Dp[p + 1][now] = max(Dp[p][b - 1] + 1, Dp[p + 1][now]);
      } else
        Dp[p + 1][now] = max(Dp[p][b - 1], Dp[p + 1][now]);
    } else
      for (int k = 0; k < 26; ++k) {
        for (int i = b - 2; ~i; --i) {
          if (Dp[p][i] == -1) continue;
          now = La[i + 1][k];
          Dp[p + 1][now] = max(Dp[p][i], Dp[p + 1][now]);
        }
        if (Dp[p][b - 1] == -1) continue;
        now = La[b][k];
        if (now == b) {
          now = Ne[now + 1] - 1;
          Dp[p + 1][now] = max(Dp[p][b - 1] + 1, Dp[p + 1][now]);
        } else
          Dp[p + 1][now] = max(Dp[p][b - 1], Dp[p + 1][now]);
      }
  }
  ans = 0;
  for (int i = 0; i < b; ++i) ans = max(ans, Dp[a][i]);
  printf("%d\n", ans);
  return 0;
}
