#include <bits/stdc++.h>
using namespace std;
string S, T;
int s, t;
int bk[3505], nxt[3505][26];
void BK() {
  bk[1] = 0;
  for (int i = (1); i <= (t - 1); i += (1)) {
    int f = bk[i];
    while (f && T[f] != T[i]) f = bk[f];
    if (T[f] == T[i]) f++;
    bk[i + 1] = f;
  }
}
vector<vector<int> > memo;
int dp(int i, int j) {
  if (i == s) return 0;
  if (memo[i][j] != -1) return memo[i][j];
  int mx = 0;
  if (S[i] == '?') {
    for (int k = (0); k <= (25); k += (1))
      mx = max(mx, dp(i + 1, nxt[j][k]) + (nxt[j][k] == t));
  } else {
    mx = dp(i + 1, nxt[j][S[i] - 'a']) + (nxt[j][S[i] - 'a'] == t);
  }
  return memo[i][j] = mx;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> S >> T;
  s = S.length();
  t = T.length();
  if (t > s) {
    printf("0\n");
    return 0;
  }
  BK();
  nxt[0][T[0] - 'a'] = 1;
  for (int i = (1); i <= (t); i += (1)) {
    int f = bk[i];
    memcpy(nxt[i], nxt[f], sizeof(nxt[f]));
    if (i < t) nxt[i][T[i] - 'a'] = i + 1;
  }
  memo.resize(s + 5);
  for (int i = (0); i <= (s + 1); i += (1)) {
    memo[i].resize(t + 5);
    for (int j = (0); j <= (t + 1); j += (1)) memo[i][j] = -1;
  }
  printf("%d\n", dp(0, 0));
  return 0;
}
