#include <bits/stdc++.h>
using namespace std;
vector<int> calcPi(string &pattern) {
  vector<int> pi(pattern.size(), 0);
  for (int i = 1; i < pattern.size(); ++i) {
    int j = pi[i - 1];
    while (j > 0 && pattern[i] != pattern[j]) {
      j = pi[j - 1];
    }
    if (pattern[i] == pattern[j]) {
      ++j;
    }
    pi[i] = j;
  }
  return pi;
}
void calcNext(string &pattern, vector<int> &patternPi,
              vector<vector<int>> &nxt) {
  for (int i = 0; i <= pattern.size(); ++i) {
    for (char c = 'a'; c <= 'z'; ++c) {
      int j = i;
      while (j > 0 && pattern[j] != c) {
        j = patternPi[j - 1];
      }
      if (pattern[j] == c) {
        ++j;
      }
      nxt[i][c - 'a'] = j;
    }
  }
}
string goodChars;
int dp(int idx, int len, int patternLen, string &test, vector<vector<int>> &nxt,
       vector<vector<int>> &memo) {
  if (idx == test.size()) {
    return 0;
  }
  if (memo[idx][len] != -1) {
    return memo[idx][len];
  }
  int &ret = memo[idx][len];
  ret = 0;
  if (test[idx] != '?') {
    int nextLen = nxt[len][test[idx] - 'a'];
    ret = dp(idx + 1, nextLen, patternLen, test, nxt, memo) +
          (nextLen == patternLen);
  } else {
    for (char c : goodChars) {
      int nextLen = nxt[len][c - 'a'];
      ret = max(ret, dp(idx + 1, nextLen, patternLen, test, nxt, memo) +
                         (nextLen == patternLen));
    }
  }
  return ret;
}
int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  string test, pattern;
  cin >> test >> pattern;
  if (pattern.size() > test.size()) {
    cout << 0 << endl;
    return 0;
  }
  set<char> s;
  for (char c : pattern) s.insert(c);
  for (char c = 'a'; c <= 'z'; ++c)
    if (s.count(c)) goodChars += c;
  vector<int> pi = calcPi(pattern);
  vector<vector<int>> nxt =
      vector<vector<int>>(pattern.size() + 1, vector<int>(26, 0));
  calcNext(pattern, pi, nxt);
  vector<vector<int>> memo =
      vector<vector<int>>(test.size(), vector<int>(pattern.size() + 1, -1));
  cout << dp(0, 0, pattern.size(), test, nxt, memo) << '\n';
  return 0;
}
