#include <bits/stdc++.h>
using namespace std;
const int N = 100100, E = 11000000;
int n, m, tp, P[N], to[N][26], dp[E];
char A[N], B[N];
int main() {
  scanf("%s%s", A + 1, B + 1);
  n = strlen(A + 1), m = strlen(B + 1);
  P[0] = -1;
  for (int i = 1; i <= m; ++i) {
    int j = i - 1;
    while (j && B[P[j] + 1] != B[i]) j = P[j];
    P[i] = P[j] + 1;
  }
  for (int i = 0; i <= m; ++i) {
    for (int j = 0; j <= 25; ++j) {
      if (j + 'a' == B[i + 1])
        to[i][j] = i + 1;
      else
        to[i][j] = to[P[i]][j];
    }
  }
  memset(dp, -60, sizeof(dp));
  dp[(0) * (m + 1) + (0)] = 0;
  for (int i = 0; i <= n - 1; ++i) {
    for (int j = 0; j <= m; ++j) {
      if (dp[(i) * (m + 1) + (j)] < 0) continue;
      if (A[i + 1] == '?') {
        for (int c = 0; c <= 25; ++c) {
          int k = to[j][c];
          if (k == m)
            dp[(i + 1) * (m + 1) + (m)] =
                max(dp[(i + 1) * (m + 1) + (m)], dp[(i) * (m + 1) + (j)] + 1);
          else
            dp[(i + 1) * (m + 1) + (k)] =
                max(dp[(i + 1) * (m + 1) + (k)], dp[(i) * (m + 1) + (j)]);
        }
      } else {
        int k = to[j][A[i + 1] - 'a'];
        if (k == m)
          dp[(i + 1) * (m + 1) + (m)] =
              max(dp[(i + 1) * (m + 1) + (m)], dp[(i) * (m + 1) + (j)] + 1);
        else
          dp[(i + 1) * (m + 1) + (k)] =
              max(dp[(i + 1) * (m + 1) + (k)], dp[(i) * (m + 1) + (j)]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i <= m; ++i) ans = max(ans, dp[(n) * (m + 1) + (i)]);
  printf("%d", ans);
  return 0;
}
