#include <bits/stdc++.h>
using namespace std;
void getPi(string t, vector<int> &pi) {
  pi = vector<int>(t.size(), 0);
  int j = 0;
  for (int i = 1; i < t.size(); i++) {
    while (j > 0 && t[i] != t[j]) j = pi[j - 1];
    if (t[i] == t[j]) pi[i] = ++j;
  }
}
void KMP(string s, string t, vector<int> &kmp, vector<int> &pi) {
  getPi(t, pi);
  int j = 0;
  for (int i = 0; i < s.size(); i++) {
    while (j > 0 && s[i] != t[j]) j = pi[j - 1];
    if (s[i] == t[j]) {
      if (j == t.size() - 1) {
        kmp.push_back(i);
        j = pi[j];
      } else
        j++;
    }
  }
}
string S, T;
vector<int> kmp, pi;
vector<vector<int> > dp, prec;
int main() {
  getline(cin, S);
  getline(cin, T);
  if (T.size() > S.size()) {
    printf("0");
    return 0;
  }
  KMP(S, T, kmp, pi);
  prec = vector<vector<int> >(T.size() + 1, vector<int>(26, 0));
  for (int i = 0; i <= T.size(); i++) {
    for (int j = 0; j < 26; j++) {
      char ch = 'a' + j;
      int k = i == T.size() ? pi.back() : i;
      while (k > 0 && T[k] != ch) k = pi[k - 1];
      if (T[k] == ch) prec[i][j] = ++k;
    }
  }
  dp = vector<vector<int> >(S.size(), vector<int>(T.size() + 1, 0));
  for (int i = S.size() - 1; i >= 0; i--) {
    for (int j = 0; j <= T.size(); j++) {
      if (i == S.size() - 1)
        dp[i][j] = j == T.size();
      else if (S[i + 1] != '?')
        dp[i][j] = (j == T.size()) + dp[i + 1][prec[j][S[i + 1] - 'a']];
      else {
        for (int k = 0; k < 26; k++) {
          dp[i][j] = max(dp[i][j], (j == T.size()) + dp[i + 1][prec[j][k]]);
        }
      }
    }
  }
  int ans = 0;
  if (S[0] == '?')
    for (int i = 0; i < 26; i++) ans = max(ans, dp[0][(T[0] - 'a' == i)]);
  else
    ans = dp[0][T[0] == S[0]];
  printf("%d", ans);
}
