#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const long long M = 1e9 + 7;
const long long inf = 1e18 + 5;
vector<int> pre_fn(string &s) {
  int n = s.size();
  vector<int> pre(n);
  int pos = 0;
  pre[0] = 0;
  for (int i = 1; i < n; i++) {
    while (pos and s[pos] != s[i]) pos = pre[pos - 1];
    if (s[pos] == s[i]) pos++;
    pre[i] = pos;
  }
  return pre;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s, t;
  cin >> s >> t;
  int n = s.size();
  int m = t.size();
  vector<int> pre = pre_fn(t);
  int a[m][26];
  for (int i = 0; i < m; i++) {
    for (int c = 0; c < 26; c++) {
      if (i and t[i] != 'a' + c)
        a[i][c] = a[pre[i - 1]][c];
      else
        a[i][c] = i + (t[i] == 'a' + c);
    }
  }
  int dp[n + 1][m + 1];
  memset(dp, -1, sizeof(dp));
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (dp[i][j] != -1) {
        if (s[i] == '?') {
          for (int k = 0; k < 26; k++) {
            int get = a[j][k];
            if (get == m)
              dp[i + 1][pre[m - 1]] = max(dp[i][j] + 1, dp[i + 1][pre[m - 1]]);
            else
              dp[i + 1][get] = max(dp[i + 1][get], dp[i][j]);
          }
        } else {
          int get = a[j][s[i] - 'a'];
          if (get == m)
            dp[i + 1][pre[m - 1]] = max(dp[i][j] + 1, dp[i + 1][pre[m - 1]]);
          else
            dp[i + 1][get] = max(dp[i + 1][get], dp[i][j]);
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i <= m; i++) ans = max(ans, dp[n][i]);
  cout << ans << "\n";
}
