#include <bits/stdc++.h>
using namespace std;
const int limit = 26;
vector<vector<int>> build_automaton(string s) {
  s += '#';
  int n = (int)s.size();
  vector<vector<int>> ans(n, vector<int>(limit));
  vector<int> fail(n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < limit; j++) {
      if (i == 0) {
        if (s[i] == j + 'a') {
          ans[i][j] = i + 1;
        } else {
          ans[i][j] = 0;
        }
      } else {
        if (s[i] == j + 'a') {
          ans[i][j] = i + 1;
        } else {
          ans[i][j] = ans[fail[i - 1]][j];
        }
      }
    }
    if (i == 0) {
      continue;
    }
    int j = fail[i - 1];
    while (j > 0 && s[i] != s[j]) {
      j = fail[j - 1];
    }
    fail[i] = j + (s[i] == s[j]);
  }
  return ans;
}
string s, t;
int ss, st;
vector<vector<int>> aut;
vector<vector<int>> dp;
vector<int> pre;
int get(int on_s, int state) {
  if (on_s == ss) {
    return 0;
  }
  int &ans = dp[on_s][state];
  if (ans != -1) {
    return ans;
  }
  ans = 0;
  if (s[on_s] == '?') {
    for (int i = 0; i < limit; i++) {
      ans = max(ans, (aut[state][i] == st) + get(on_s + 1, aut[state][i]));
    }
  } else {
    ans = (aut[state][s[on_s] - 'a'] == st) +
          get(on_s + 1, aut[state][s[on_s] - 'a']);
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> s >> t;
  aut = build_automaton(t);
  ss = (int)s.size();
  st = (int)t.size();
  dp.resize(ss + 2);
  for (int i = 0; i < ss + 2; i++) {
    dp[i].resize(st + 2);
    for (int j = 0; j < st + 2; j++) {
      dp[i][j] = -1;
    }
  }
  cout << get(0, 0) << '\n';
  return 0;
}
