#include <bits/stdc++.h>
using namespace std;
long long n, m, pi[100005], q, a, b, c, dp[100005][2], k, i, j, ans;
string t, p;
int main() {
  cin >> t >> p;
  t = '#' + t;
  p = '#' + p;
  m = p.size() - 1;
  pi[1] = 0;
  q = 0;
  for (int i = 2; i < p.size(); i++) {
    while (p[i] != p[q + 1] && q > 0) {
      q = pi[q];
    }
    if (p[q + 1] == p[i]) {
      q++;
    }
    pi[i] = q;
  }
  if (t.size() < p.size()) {
    cout << 0;
    return 0;
  }
  dp[k][0] = 0;
  for (int k = 1; k < p.size(); k++) {
    dp[k][0] = -1;
  }
  for (i = 1; i < t.size(); i++) {
    dp[0][1] = dp[0][0];
    for (j = 1; j < m; j++) {
      if (t[i] == '?' || t[i] == p[j]) {
        dp[j][1] = dp[j - 1][0];
      } else {
        dp[j][1] = -1;
      }
    }
    if (dp[m - 1][0] > -1 && (t[i] == '?' || p[m] == t[i])) {
      ans = max(ans, dp[m - 1][0] + 1);
      q = p.size() - 1;
      while (q > 0) {
        q = pi[q];
        dp[q][1] = max(dp[q][1], dp[m - 1][0] + 1);
      }
    }
    for (int k = 0; k < p.size(); k++) {
      dp[k][0] = dp[k][1];
    }
    cout << endl;
  }
  cout << ans;
  return 0;
}
