#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream &operator<<(ostream &os, vector<T> V) {
  os << "[ ";
  for (auto v : V) os << v << " ";
  return os << "]";
}
template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
const long long INF = 1e18;
const long long N = 1e5;
const long long M = 1e9 + 7;
inline long long ch(char c) { return c - 'a'; }
const long long A = 26;
void calc_pi(const string &s, long long *pi) {
  if (!(long long)(s).size()) return;
  pi[0] = 0;
  for (long long i = 1; i <= (long long)(s).size() - 1; ++i) {
    1;
    long long j = pi[i - 1];
    for (; j > 0 && s[i] != s[j]; j = pi[j - 1])
      ;
    1;
    pi[i] = j ? j + 1 : s[i] == s[j];
  }
}
void calc_tr(string &s, long long *pi, long long tr[][A]) {
  if (!(long long)(s).size()) return;
  for (long long p = 0; p < (long long)(s).size() + 1; ++p)
    for (long long c = 0; c < 26; ++c) {
      long long j = p;
      for (; j > 0 && c != ch(s[j]); j = pi[j - 1])
        ;
      tr[p][c] = j ? j + 1 : c == ch(s[j]);
      1;
      if (p == 3 && c == 11) 1;
    }
}
inline long long m(long long i) { return (i + 1) & 1; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s, t;
  cin >> s >> t;
  if ((long long)(t).size() > (long long)(s).size()) {
    cout << 0 << '\n';
    return 0;
  }
  long long pi[(long long)(t).size() + 5];
  long long tr[(long long)(t).size() + 5][A];
  calc_pi(t, pi);
  calc_tr(t, pi, tr);
  long long dp[2][(long long)(t).size() + 5];
  memset(dp, -1, sizeof dp);
  dp[0][0] = 0;
  for (long long i = 0; i < (long long)(s).size(); ++i) {
    memset(dp[m(i)], -1, sizeof dp[m(i)]);
    1;
    if (s[i] == '?') {
      for (long long j = 0; j < (long long)(t).size() + 1; ++j) {
        if (dp[m(i - 1)][j] == -1) continue;
        for (long long c = 0; c < A; ++c) {
          auto &d = dp[m(i)][tr[j][c]];
          if (d <= dp[m(i - 1)][j]) {
            d = dp[m(i - 1)][j];
            if (tr[j][c] == (long long)(t).size()) ++d;
          }
        }
      }
    } else {
      for (long long j = 0; j < (long long)(t).size() + 1; ++j) {
        if (dp[m(i - 1)][j] == -1) continue;
        long long c = ch(s[i]);
        1;
        auto &d = dp[m(i)][tr[j][c]];
        1;
        1;
        1;
        if (d <= dp[m(i - 1)][j]) {
          d = dp[m(i - 1)][j];
          if (tr[j][c] == (long long)(t).size()) ++d;
        }
      }
    }
  }
  auto &d = dp[m((long long)(s).size() - 1)];
  long long ans = *max_element(d, d + (long long)(t).size() + 1);
  cout << (ans) << '\n';
  ;
}
