#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char c = getchar();
  int x = 0;
  bool f = 0;
  for (; !isdigit(c); c = getchar()) f ^= !(c ^ 45);
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
  if (f) x = -x;
  return x;
}
char s[100005], t[100005];
int n, p, f[100005], mx[100005], nxt[100005], m;
bool ok(int x) {
  for (register int i = (0); i <= (m - 1); ++i)
    if (s[x - i] != '?' && s[x - i] != t[m - i]) return 0;
  return 1;
}
signed main() {
  cin >> s + 1 >> t + 1, n = strlen(s + 1), m = strlen(t + 1);
  for (register int i = (2); i <= (m); ++i) {
    while (p && t[p + 1] != t[i]) p = nxt[p];
    if (t[p + 1] == t[i]) p++;
    nxt[i] = p;
  }
  int res = 0;
  for (register int i = (1); i <= (n); ++i) {
    if (!ok(i)) {
      mx[i] = mx[i - 1];
      continue;
    }
    f[i] = mx[i - m] + 1;
    for (int j = nxt[m]; j; j = nxt[j]) f[i] = max(f[i], f[i - m + j] + 1);
    mx[i] = max(mx[i - 1], f[i]);
  }
  cout << mx[n];
  return 0;
}
