#include <bits/stdc++.h>
using namespace std;
vector<int> G[2 * 100000 + 5];
int till[100000 + 5];
int lps[100000 + 5];
void computeLPSArray(string &pat) {
  int M = pat.size();
  int len = 0;
  lps[0] = 0;
  int i = 1;
  while (i < M) {
    if (pat[i] == pat[len]) {
      len++;
      lps[i] = len;
      i++;
    } else {
      if (len != 0) {
        len = lps[len - 1];
      } else {
        lps[i] = 0;
        i++;
      }
    }
  }
}
string S, T;
vector<vector<int>> fdp, dp;
int rec(int i, int j) {
  if (i + j == S.size()) {
    return j == T.size();
  }
  if (fdp[i][j]) return dp[i][j];
  fdp[i][j] = 1;
  dp[i][j] = j > 0 ? rec(i + j - lps[j - 1], lps[j - 1]) : rec(i + 1, 0);
  if (j == T.size()) {
    return dp[i][j] = 1 + rec(i + j - lps[j - 1], lps[j - 1]);
  }
  if (S[i + j] == '?' or S[i + j] == T[j])
    dp[i][j] = max(dp[i][j], rec(i, j + 1));
  return dp[i][j];
}
int main() {
  cin >> S >> T;
  computeLPSArray(T);
  vector<vector<int>> V(S.size() + 2, vector<int>(T.size() + 2, 0));
  dp = fdp = V;
  cout << rec(0, 0);
}
