#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r) {
  uniform_int_distribution<int> uid(l, r);
  return uid(rng);
}
const int N = 1e5 + 5;
vector<int> dp[N];
int lcp[N];
pair<int, int> go[N][26];
void upd(int &x, int y) { x = max(x, y); }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  string s, t;
  cin >> s >> t;
  int pt = 0;
  for (int i = 1; i <= (int)t.size() - 1; i++) {
    while (pt > 0 && t[pt] != t[i]) pt = lcp[pt - 1];
    if (t[pt] == t[i]) pt++;
    lcp[i] = pt;
  }
  for (int i = 0; i <= (int)s.size(); i++) {
    dp[i].resize((int)t.size(), -1e9);
  }
  dp[0][0] = 0;
  for (int i = 0; i <= (int)t.size() - 1; i++) {
    for (int j = 0; j <= 25; j++) {
      char ch = 'a' + j;
      pair<int, int> p = {0, 0};
      int pt = i;
      if (t[pt] == ch)
        pt++;
      else if (pt != 0)
        pt = go[lcp[pt - 1]][j].first;
      if (pt == (int)t.size()) {
        pt = lcp[pt - 1];
        p.second = 1;
      }
      p.first = pt;
      go[i][j] = p;
    }
  }
  dp[0][0] = 0;
  for (int i = 0; i <= (int)s.size() - 1; i++) {
    char ch = s[i];
    for (int j = 0; j <= (int)t.size() - 1; j++) {
      if (dp[i][j] == -1e9) continue;
      if (ch == '?') {
        for (int k = 0; k <= 25; k++) {
          upd(dp[i + 1][go[j][k].first], dp[i][j] + go[j][k].second);
        }
      } else {
        upd(dp[i + 1][go[j][ch - 'a'].first],
            dp[i][j] + go[j][ch - 'a'].second);
      }
    }
  }
  int ans = 0;
  for (int j = 0; j <= (int)t.size() - 1; j++) {
    ans = max(ans, dp[(int)s.size()][j]);
  }
  cout << ans;
  return 0;
}
