#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string a, b;
  cin >> a >> b;
  int n = b.size();
  vector<int> pi(n);
  for (int i = 1; i < n; i++) {
    int j = pi[i - 1];
    while (j > 0 && b[i] != b[j]) {
      j = pi[j - 1];
    }
    if (b[i] == b[j]) {
      j++;
    }
    pi[i] = j;
  }
  vector<vector<int>> aut(n, vector<int>(26));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 26; j++) {
      char ch = j + 'a';
      int u = i;
      if (i > 0 && ch != b[i]) {
        u = aut[pi[i - 1]][j];
      }
      if (ch == b[i]) {
        u++;
      }
      aut[i][j] = u;
    }
  }
  int m = a.size();
  int N = 27;
  vector<int> mp(n + 1, -1);
  vector<char> L(N);
  for (int i = 1; i < N; i++) {
    L[i] = 'a' + i - 1;
  }
  mp[0] = 0;
  int d = 0, f = 27;
  for (int i = 0; i < m; i++) {
    if (a[i] == '?') {
      d = 1, f = 27;
    } else {
      L[0] = a[i];
      d = 0, f = 1;
    }
    vector<int> nmp(n + 1, -1);
    for (int kk = 0; kk <= n; kk++) {
      if (mp[kk] != -1) {
        for (int k = d; k < f; k++) {
          int j = aut[kk][L[k] - 'a'];
          int ans = mp[kk];
          if (j == n) {
            j = pi[j - 1];
            ans++;
          }
          nmp[j] = max(ans, nmp[j]);
        }
      }
    }
    mp.swap(nmp);
  }
  int ans = 0;
  ans = max(ans, *max_element(mp.begin(), mp.end()));
  cout << ans << "\n";
  return 0;
}
