#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
string s, pat;
int fail[N], searchDp[N][26];
vector<vector<int> > dp;
void KMP() {
  int patLen = pat.length();
  for (int i = 1, k = 0; i < patLen; i++) {
    while (k > 0 && pat[i] != pat[k]) k = fail[k - 1];
    if (pat[i] == pat[k]) k++;
    fail[i] = k;
  }
}
int match(int j, char x) {
  if (searchDp[j][x - 'a'] != -1) return searchDp[j][x - 'a'];
  int init = j;
  while (j && pat[j] != x) j = fail[j - 1];
  return searchDp[init][x - 'a'] = j + (pat[j] == x);
}
int solve(int i, int j) {
  if (i == s.length()) return j == pat.length();
  if (j == pat.length()) return 1 + solve(i, fail[j - 1]);
  if (dp[i][j] != -1) return dp[i][j];
  int ans = 0;
  if (s[i] == '?') {
    for (int k = 0; k < 26; k++) {
      ans = max(ans, solve(i + 1, match(j, 'a' + k)));
    }
  } else {
    ans = max(ans, solve(i + 1, match(j, s[i])));
  }
  return dp[i][j] = ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> s >> pat;
  KMP();
  dp =
      vector<vector<int> >((int)s.length(), vector<int>((int)pat.length(), -1));
  memset(searchDp, -1, sizeof searchDp);
  cout << solve(0, 0);
  return 0;
}
