#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 7;
int z[MAXN], nxt[MAXN][26] = {};
void maximize(int &a, const int &b) {
  if (a < b) a = b;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  string s, t;
  cin >> s >> t;
  int ns = (int)s.size(), nt = (int)t.size();
  if (nt > ns) return cout << 0, 0;
  s = '@' + s, t = '@' + t;
  vector<vector<int> > dp(ns + 1, vector<int>(nt + 1, -1));
  for (int sta = 0; sta <= nt; ++sta)
    for (int c = 0; c < 26; ++c) {
      string st = t;
      for (int i = 1; i <= sta; ++i) st.push_back(t[i]);
      st.push_back((char)(c + 'a'));
      int n = (int)st.size() - 1, l = 1, r = 0;
      z[1] = n;
      for (int i = 2; i <= n; ++i) {
        if (i > r) {
          r = l = i;
          while (r <= n && st[r] == st[r - l + 1]) ++r;
          z[i] = r - l, --r;
        } else if (z[i - l + 1] < r - i + 1) {
          z[i] = z[i - l + 1];
        } else {
          l = i;
          while (r <= n && st[r] == st[r - l + 1]) ++r;
          z[i] = r - l, --r;
        }
        if (n - i + 1 <= nt && i > nt && i + z[i] - 1 == n) {
          nxt[sta][c] = z[i];
          break;
        }
      }
    }
  dp[0][0] = 0;
  for (int i = 0; i < ns; ++i)
    for (int j = 0; j <= nt; ++j)
      if (dp[i][j] != -1) {
        if (s[i + 1] == '?') {
          for (int c = 0; c < 26; ++c)
            maximize(dp[i + 1][nxt[j][c]], dp[i][j] + (nxt[j][c] == nt));
        } else {
          int c = s[i + 1] - 'a';
          maximize(dp[i + 1][nxt[j][c]], dp[i][j] + (nxt[j][c] == nt));
        }
      }
  int res = 0;
  for (int i = 0; i <= nt; ++i) res = max(res, dp[ns][i]);
  cout << res;
  return 0;
}
