#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
const int INF = 1e9;
int n, m, dp[maxn], dp1[maxn], f[maxn];
string s, t;
bool ok(int i) {
  int l = i - m + 1;
  if (l < 0) return false;
  for (int j = l; j <= i; j++)
    if (s[j] != '?' && s[j] != t[j - l]) return false;
  return true;
}
void kmp_build() {
  f[0] = 0;
  for (int i = 1; i < m; i++) {
    int po = f[i - 1];
    while (po > 0 && t[i] != t[po]) po = f[po - 1];
    if (t[i] == t[po]) po++;
    f[i] = po;
  }
}
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> s >> t;
  n = s.size();
  m = t.size();
  kmp_build();
  dp1[0] = -INF;
  dp[0] = 0;
  for (int i = 1; i <= n; i++) {
    if (ok(i - 1)) {
      dp1[i] = max(dp1[i], dp[i - m] + 1);
      int po = f[m - 1];
      while (po > 0) {
        dp1[i] = max(dp1[i], dp1[i - m + po] + 1);
        po = f[po - 1];
      }
    } else {
      dp1[i] = -INF;
    }
    dp[i] = max(dp[i - 1], dp1[i]);
  }
  cout << dp[n];
  return 0;
}
