#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char c = getchar();
  int x = 0, f = 1;
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  return x * f;
}
inline void chkmax(int &x, int y) { x = x > y ? x : y; }
const int MAXN = 1e5 + 5;
const int INF = 1e9;
int ch[MAXN][26], fail[MAXN];
int N, M, cnt;
bool nd[MAXN];
char s[MAXN], t[MAXN];
vector<int> dp[MAXN];
inline void build() {
  int p = 0;
  for (int i = 1; i <= M; i++) {
    int x = t[i] - 'a';
    ch[p][x] = ++cnt;
    p = ch[p][x];
  }
  nd[p] = true;
  queue<int> Q;
  for (int i = 0; i < 26; i++)
    if (ch[0][i]) Q.push(ch[0][i]);
  while (!Q.empty()) {
    int x = Q.front();
    Q.pop();
    for (int i = 0; i < 26; i++)
      if (!ch[x][i])
        ch[x][i] = ch[fail[x]][i];
      else {
        int y = ch[x][i];
        fail[y] = ch[fail[x]][i];
        Q.push(y);
      }
  }
}
int main() {
  scanf("%s", s + 1);
  scanf("%s", t + 1);
  N = strlen(s + 1);
  M = strlen(t + 1);
  build();
  for (int i = 0; i <= N; i++) {
    dp[i].resize(M + 1);
    for (int j = 0; j <= M; j++) dp[i][j] = -INF;
  }
  dp[0][0] = 0;
  for (int i = 0; i < N; i++)
    if (s[i + 1] != '?') {
      int t = s[i + 1] - 'a';
      for (int j = 0; j <= M; j++) {
        int p = ch[j][t];
        chkmax(dp[i + 1][p], dp[i][j] + nd[p]);
      }
    } else {
      for (int t = 0; t < 26; t++)
        for (int j = 0; j <= M; j++) {
          int p = ch[j][t];
          chkmax(dp[i + 1][p], dp[i][j] + nd[p]);
        }
    }
  int ans = 0;
  for (int i = 0; i <= M; i++) chkmax(ans, dp[N][i]);
  printf("%d\n", ans);
  return 0;
}
