#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using ll = long long;
vi prefix_function(string &s) {
  int n = int((s).size()), j = 0;
  vi pre(n);
  for (int i = int(1); i < int(n); i++) {
    while (j > 0 && s[i] != s[j]) j = pre[j - 1];
    pre[i] = s[i] == s[j] ? ++j : j;
  }
  return pre;
}
vector<vi> kmp_automaton(string &s) {
  s += '#';
  int n = int((s).size());
  vi pre = prefix_function(s);
  vector<vi> aut(n, vi(26));
  for (int i = int(0); i < int(n); i++)
    for (int c = int(0); c < int(26); c++) {
      if (i > 0 && 'a' + c != s[i])
        aut[i][c] = aut[pre[i - 1]][c];
      else
        aut[i][c] = i + ('a' + c == s[i]);
    }
  return aut;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string t, s;
  cin >> t >> s;
  int m = int((t).size()), n = int((s).size());
  vector<vi> aut = kmp_automaton(s), dp(m + 1, vi(n + 1));
  for (int i = int(m - 1); i >= int(0); i--)
    for (int j = int(0); j < int(n + 1); j++) {
      int &x = dp[i][j];
      if (t[i] == '?') {
        for (int c = int(0); c < int(26); c++) {
          int v = aut[j][c];
          x = max(x, dp[i + 1][v] + (v == n));
        }
      } else {
        int v = aut[j][int(t[i] - 'a')];
        x = dp[i + 1][v] + (v == n);
      }
    }
  cout << dp[0][0] << '\n';
  return 0;
}
