#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O2")
const int MX = 1e5 + 10;
string s, t;
int n, m;
int f[MX], nxt[MX][30];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> s >> t;
  n = s.size();
  m = t.size();
  f[0] = -1;
  for (int i = 2; i <= m; i++) {
    int k = f[i - 1];
    while (k >= 0 && t[k] != t[i - 1]) k = f[k];
    f[i] = k + 1;
  }
  nxt[0][t[0] - 'a']++;
  for (int i = 1; i <= m; i++) {
    for (int j = 0; j < 26; j++) {
      if (i == m || t[i] != 'a' + j)
        nxt[i][j] = nxt[f[i]][j];
      else
        nxt[i][j] = i + 1;
    }
  }
  int dp[n + 5][m + 5];
  memset(dp, -63, sizeof(dp));
  dp[0][0] = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j <= m; j++)
      for (int h = 0; h < 26; h++)
        if (s[i] == '?' || s[i] == h + 'a')
          dp[i + 1][nxt[j][h]] =
              max(dp[i][j] + (nxt[j][h] == m), dp[i + 1][nxt[j][h]]);
  int ans = 0;
  for (int i = 0; i <= m; i++) ans = max(ans, dp[n][i]);
  cout << ans << endl;
  return 0;
}
