#include <bits/stdc++.h>
#pragma GCC optimize 2
using namespace std;
int kmp[100005], F[100005][30];
vector<int> dp[100005];
int main(int argc, char** argv) {
  string a, b;
  int n, m;
  cin >> a >> b;
  n = a.size(), m = b.size();
  a = ' ' + a;
  b = ' ' + b;
  int j = 0;
  for (int i = 2; i <= m; i++) {
    while (j && b[i] != b[j + 1]) j = kmp[j];
    if (b[i] == b[j + 1]) ++j;
    kmp[i] = j;
  }
  for (int i = 1; i <= m; i++) {
    for (int j = 'a'; j <= 'z'; j++) {
      if (b[i + 1] == j)
        F[i][j - 'a'] = i;
      else
        F[i][j - 'a'] = F[kmp[i]][j - 'a'];
    }
  }
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) dp[i].push_back(-1e9);
  }
  dp[0][0] = 0;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] != '?') {
      for (int j = 0; j < m; j++) {
        if (a[i] == b[j + 1] || a[i] == '?') {
          if (j + 1 < m)
            dp[i][j + 1] = max(dp[i][j + 1], dp[i - 1][j]);
          else
            dp[i][kmp[m]] = max(dp[i][kmp[m]], dp[i - 1][j] + 1);
        } else {
          int now = j;
          now = F[now][a[i] - 'a'];
          if (a[i] == b[now + 1])
            dp[i][now + 1] = max(dp[i][now + 1], dp[i - 1][j]);
          else
            dp[i][now] = max(dp[i][now], dp[i - 1][j]);
        }
      }
    } else {
      for (int k = 'a'; k <= 'z'; k++) {
        a[i] = k;
        for (int j = 0; j < m; j++) {
          if (a[i] == b[j + 1] || a[i] == '?') {
            if (j + 1 < m)
              dp[i][j + 1] = max(dp[i][j + 1], dp[i - 1][j]);
            else
              dp[i][kmp[m]] = max(dp[i][kmp[m]], dp[i - 1][j] + 1);
          } else {
            int now = j;
            now = F[now][a[i] - 'a'];
            if (a[i] == b[now + 1])
              dp[i][now + 1] = max(dp[i][now + 1], dp[i - 1][j]);
            else
              dp[i][now] = max(dp[i][now], dp[i - 1][j]);
          }
        }
      }
      a[i] = '?';
    }
  }
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= m; j++) ans = max(ans, dp[i][j]);
  cout << ans;
  return 0;
}
