#include <bits/stdc++.h>
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
using namespace std;
const long long N = 1e5 + 5;
const long long mod = 1e9 + 7;
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int INFi = 0x7f7f7f7f;
int n, m, lps[N], aut[N][26];
vector<vector<long long> > dp;
string second, t;
void LPS() {
  lps[0] = 0;
  for (int i = 1; i < m; i++) {
    int j = lps[i - 1];
    while (j > 0 && t[i] != t[j]) j = lps[j - 1];
    lps[i] = j + (t[i] == t[j]);
  }
}
void automaton() {
  t += '#';
  LPS();
  for (int i = 0; i <= m; i++) {
    for (int j = 0; j < 26; j++) {
      if (i > 0 && j + 'a' != t[i])
        aut[i][j] = aut[lps[i - 1]][j];
      else
        aut[i][j] = i + (j + 'a' == t[i]);
    }
  }
}
long long mem(int i, int j) {
  if (i == n) return j == m;
  long long &ans = dp[i][j];
  if (ans != -1) return ans;
  if (second[i] == '?') {
    for (int c = 0; c < 26; c++) {
      ans = max(ans, mem(i + 1, aut[j][c]) + (j == m));
    }
  } else
    ans = mem(i + 1, aut[j][second[i] - 'a']) + (j == m);
  return ans;
}
void solve() {
  cin >> second >> t;
  n = second.size();
  m = t.size();
  automaton();
  dp = vector<vector<long long> >(n + 1, vector<long long>(m + 1, -1));
  cout << mem(0, 0) << "\n";
  ;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed;
  cout << setprecision(15);
  ;
  int test = 1;
  for (int i = 1; i <= test; i++) {
    solve();
  }
}
