#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long inf = (1LL << 60);
const double pi = acos(-1);
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
inline void pcas(int ca) { printf("Case %d: ", ca); }
const int maxn = 1e5 + 10;
int nex[maxn];
char s[maxn], t[maxn];
int dp[maxn], cnt[maxn];
int lens, lent;
void kmp() {
  nex[0] = -1;
  int j = -1;
  int i = 0;
  while (i < lent) {
    while (j != -1 && t[i] != t[j]) j = nex[j];
    nex[++i] = ++j;
  }
}
int main() {
  scanf("%s", s);
  scanf("%s", t);
  lens = strlen(s), lent = strlen(t);
  kmp();
  if (lens < lent) {
    cout << 0;
    return 0;
  }
  bool flag;
  for (int i = lent - 1; i < lens; ++i) {
    flag = 1;
    for (int j = 0; j < lent; ++j) {
      if (s[i - j] != t[lent - j - 1] && s[i - j] != '?') {
        flag = 0;
        break;
      }
    }
    dp[i] = dp[i - 1];
    if (flag) {
      cnt[i] = dp[i - lent];
      for (int j = nex[lent]; ~j; j = nex[j]) {
        cnt[i] = max(cnt[i], cnt[i - lent + j]);
      }
      cnt[i]++;
      dp[i] = max(cnt[i], dp[i]);
    }
  }
  printf("%d\n", dp[lens - 1]);
  return 0;
}
