#include <bits/stdc++.h>
using namespace std;
int mem[20000007];
int can[100005];
int z[100005];
string s, t;
string x;
void calc() {
  int i;
  x = t;
  int n = x.size();
  int l = 0, r = 0, k;
  for (i = 1; i < n; i++) {
    if (i > r) {
      l = r = i;
      while (r < n && x[r - l] == x[r]) r++;
      z[i] = r - l;
      r--;
    } else {
      k = i - l;
      if (z[k] < r - i + 1)
        z[i] = z[k];
      else {
        l = i;
        while (r < n && x[r - l] == x[r]) r++;
        z[i] = r - l;
        r--;
      }
    }
  }
}
bool ok(int x) {
  int i;
  for (i = 0; i < t.size(); i++) {
    if (i + x >= s.size() || (t[i] != s[i + x] && s[i + x] != '?')) return 0;
  }
  return 1;
}
int go(int x, int y) {
  int ind = x * t.size() + y;
  if (x >= s.size()) return 0;
  if (mem[ind] != -1) return mem[ind];
  if (y == 0) {
    if (can[x])
      return mem[ind] = max(1 + go(x + 1, t.size() - 1), go(x + 1, 0));
    return mem[ind] = go(x + 1, 0);
  }
  if (z[t.size() - y] >= y && can[x])
    return mem[ind] = max(1 + go(x + 1, t.size() - 1), go(x + 1, y - 1));
  return mem[ind] = go(x + 1, y - 1);
}
int main() {
  cin >> s >> t;
  int i;
  for (i = 0; i < s.size(); i++) {
    can[i] = ok(i);
  }
  calc();
  memset(mem, -1, sizeof mem);
  cout << go(0, 0) << endl;
}
