#include <bits/stdc++.h>
using namespace std;
string s, t;
int lps[200000 + 5], aut[200000 + 5][26], s_size, t_size;
vector<vector<int>> dp;
void prefix(string &s) {
  int l = (int)s.size();
  for (int i = 0; i < l; i++) lps[i] = 0;
  for (int i = 1; i < l; i++) {
    int j = lps[i - 1];
    while (j > 0 && s[i] != s[j]) j = lps[j - 1];
    if (s[i] == s[j]) j++;
    lps[i] = j;
  }
}
void compute_automation(string s) {
  s += '#';
  int n = (int)s.size();
  prefix(s);
  for (int i = 0; i < n; i++) {
    for (int c = 0; c < 26; c++) {
      if (i > 0 && 'a' + c != s[i])
        aut[i][c] = aut[lps[i - 1]][c];
      else
        aut[i][c] = i + ('a' + c == s[i]);
    }
  }
}
int solve(int i, int j) {
  if (i == s_size) {
    if (j == t_size)
      return 1;
    else
      return 0;
  }
  if (dp[i][j] != -1) return dp[i][j];
  int ret = 0;
  if (s[i] == '?') {
    for (int c = 0; c < 26; c++) ret = max(ret, solve(i + 1, aut[j][c]));
  } else
    ret = max(ret, solve(i + 1, aut[j][s[i] - 'a']));
  if (j == t_size) ret++;
  return dp[i][j] = ret;
}
int main(int argc, const char *argv[]) {
  cin >> s >> t;
  compute_automation(t);
  s_size = (int)s.size();
  t_size = (int)t.size();
  if (s_size < t_size) {
    printf("0\n");
    return 0;
  }
  dp.resize(s_size + 1);
  for (int i = 0; i < s_size; i++) dp[i].resize(t_size + 1, -1);
  printf("%d\n", solve(0, 0));
  return 0;
}
