#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 4;
char s[MAXN], t[MAXN];
int n, m, F[MAXN];
int dp[2][MAXN], bVal[MAXN][26], bSub[MAXN][26];
int main() {
  scanf("%s%s", s, t);
  n = (int)strlen(s);
  m = (int)strlen(t);
  t[m] = '#';
  t[++m] = 0;
  if (m - 1 > n) {
    return 0 * puts("0");
  }
  F[0] = 0;
  for (int border = 0, i = 1; i < m; ++i) {
    while (border > 0 && t[i] != t[border]) border = F[border - 1];
    if (t[i] == t[border]) ++border;
    F[i] = border;
  }
  memset(dp, 0, sizeof(dp));
  for (int border = 0; border <= m; ++border) {
    for (char ch = 'a'; ch <= 'z'; ++ch) {
      int nborder = border;
      while (nborder > 0 && ch != t[nborder]) nborder = F[nborder - 1];
      if (ch == t[nborder]) ++nborder;
      bVal[border][ch - 'a'] = nborder;
      bSub[border][ch - 'a'] = (nborder == (m - 1));
    }
  }
  int cur = 0;
  for (int i = n - 1; i >= 0; --i) {
    for (int border = 0; border <= m; ++border) {
      int &ans = dp[cur][border] = 0;
      if (s[i] != '?') {
        ans = dp[cur ^ 1][bVal[border][s[i] - 'a']] + bSub[border][s[i] - 'a'];
      } else {
        for (int ch = 0; ch < 26; ++ch)
          ans = max(ans, dp[cur ^ 1][bVal[border][ch]] + bSub[border][ch]);
      }
    }
    cur ^= 1;
  }
  printf("%d\n", dp[cur ^ 1][0]);
  return 0;
}
