#include <bits/stdc++.h>
using namespace std;
const int MX = 100005;
char s[MX], t[MX];
int n, m, pi[MX], to[MX][26];
void compute(int len, char s[], int pi[]) {
  pi[0] = 0;
  for (int i = 1; i < len; i++) {
    int j = pi[i - 1];
    while (j) {
      if (s[j] == s[i]) {
        pi[i] = j + 1;
        break;
      }
      j = pi[j - 1];
    }
    if (j == 0) pi[i] = (s[i] == s[0]) ? 1 : 0;
  }
}
void make_automaton(char s[], int n, int pi[]) {
  for (int i = 0; i <= n; i++) {
    for (int c = 0; c < 26; c++) {
      if (s[i] == c + 97)
        to[i][c] = i + 1;
      else
        to[i][c] = i ? to[pi[i - 1]][c] : 0;
    }
  }
}
int f(int i, int j, vector<vector<int> > &dp) {
  if (i == m) return (j == n);
  if (dp[i][j] != -1) return dp[i][j];
  if (s[i] == '?') {
    int r1 = 0, r2 = 0, r3 = 0, k = pi[j - 1];
    if (j > 0) {
      if (j < n) r1 = f(i + 1, to[j][t[j] - 97], dp);
      r2 = f(i + 1, to[k][t[k] - 97], dp);
    }
    r3 = f(i + 1, to[j][t[0] - 97], dp);
    dp[i][j] = max({r1, r2, r3});
  } else
    dp[i][j] = f(i + 1, to[j][s[i] - 97], dp);
  if (j == n) dp[i][j]++;
  return dp[i][j];
}
int main() {
  scanf("%s %s", s, t);
  m = strlen(s), n = strlen(t);
  compute(n, t, pi);
  make_automaton(t, n, pi);
  vector<int> v(n + 2, -1);
  vector<vector<int> > dp(m + 2, v);
  printf("%d\n", f(0, 0, dp));
  return 0;
}
