#include <bits/stdc++.h>
using namespace std;
template <class TH>
void _dbg(const char *sdbg, TH h) {
  cerr << sdbg << "=" << h << "\n";
}
template <class TH, class... TA>
void _dbg(const char *sdbg, TH h, TA... a) {
  while (*sdbg != ',') cerr << *sdbg++;
  cerr << "=" << h << ",";
  _dbg(sdbg + 1, a...);
}
long long test;
long long n;
string s, t;
long long dp[500007], kmp[500007], k;
long long maks;
bool check(long long x) {
  long long kek = t.size() - 1;
  if (kek > x) return false;
  for (long long i = 0; i < (t.size()); ++i) {
    if (t[i] != s[x - kek + i] && s[x - kek + i] != '?') return false;
  }
  return true;
}
vector<long long> g;
void solve() {
  cin >> s >> t;
  for (long long i = 1; i <= (t.size() - 1); ++i) {
    while (t[k] != t[i] && k > 0) {
      k = kmp[k];
    }
    if (t[k] == t[i]) k++;
    kmp[i + 1] = k;
  }
  long long a2 = kmp[t.size()];
  while (a2 > 0) {
    g.push_back(a2);
    a2 = kmp[a2];
  }
  long long res = 0;
  long long a1 = t.size();
  for (long long i = 1; i <= (s.size()); ++i) {
    if (i >= a1) maks = max(maks, dp[i - a1]);
    if (check(i - 1)) {
      for (auto it : g) {
        dp[i] = max(dp[i], dp[i - (a1 - it)] + 1);
      }
      dp[i] = max(dp[i], maks + 1);
    }
    res = max(res, dp[i]);
  }
  cout << res;
  return;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
  test = 1;
  for (long long i = 1; i <= (test); ++i) {
    solve();
  }
  return 0;
}
