#include <bits/stdc++.h>
using namespace std;
void in(int& r) {
  static char c;
  r = 0;
  while (c = getchar(), c < 48)
    ;
  do r = (r << 1) + (r << 3) + (c ^ 48);
  while (c = getchar(), c > 47);
}
const int mn = 100005;
int f[mn];
void fail(char* p, int len) {
  f[0] = -1;
  for (int q = 1, w = -1; q < len; ++q) {
    for (; w != -1 && p[q] != p[w + 1]; w = f[w])
      ;
    if (p[q] == p[w + 1]) ++w;
    f[q] = w;
  }
}
char qw[mn], we[mn];
int dp[mn], dp1[mn];
int main() {
  scanf("%s%s", we, qw);
  int len = strlen(qw), len1 = strlen(we);
  fail(qw, len);
  for (int q(len - 1), q_end_(len1 - 1); q <= q_end_; ++q) {
    bool ok = 1;
    for (int w(q - len + 1), w_end_(q); w <= w_end_; ++w)
      if (we[w] != '?' && we[w] != qw[w - (q - len + 1)]) {
        ok = 0;
        break;
      }
    if (ok) {
      if (q - len >= 0) dp[q] = dp1[q - len];
      for (int w = f[len - 1]; w != -1; w = f[w])
        dp[q] = max(dp[q], dp[q - len + w + 1]);
      ++dp[q];
    }
    dp1[q] = max(dp[q], dp1[q - 1]);
  }
  printf("%d", dp1[len1 - 1]);
  return 0;
}
