#include <bits/stdc++.h>
using namespace std;
const int man = 1e5 + 10;
int cnt[man];
char s[man], p[man];
int nex[man], dp[man];
int len1, len2;
void getnext(char *s) {
  int j = 0, k = -1;
  nex[0] = -1;
  while (j < len2) {
    if (-1 == k || s[k] == s[j]) {
      nex[++j] = ++k;
    } else {
      k = nex[k];
    }
  }
}
bool check(int k) {
  for (int i = k, j = len2 - 1; j >= 0 && i >= 0; i--, j--) {
    if (s[i] != p[j] && s[i] != '?') {
      return false;
    }
  }
  return true;
}
int main() {
  scanf("%s%s", s, p);
  len1 = strlen(s);
  len2 = strlen(p);
  getnext(p);
  memset(dp, 0, sizeof(dp));
  memset(cnt, 0, sizeof(cnt));
  for (int i = len2 - 1; i < len1; i++) {
    dp[i] = dp[i - 1];
    if (check(i)) {
      int k = nex[len2];
      cnt[i] = dp[i - len2];
      while (-1 != k) {
        cnt[i] = max(cnt[i], cnt[i - (len2 - k)]);
        k = nex[k];
      }
      cnt[i]++;
      dp[i] = max(cnt[i], dp[i]);
    }
  }
  printf("%d\n", dp[len1 - 1]);
}
