#include <bits/stdc++.h>
using namespace std;
const int LimitLength = 1e5 + 10;
const int oo = 1e9 + 7;
const int Shift = 'a';
vector<vector<int> > F;
int Next[LimitLength][27];
int nS, nT;
char S[2 * LimitLength], T[LimitLength];
int KMP[2 * LimitLength];
int main() {
  cin >> S + 1 >> T + 1;
  nS = strlen(S + 1);
  nT = strlen(T + 1);
  KMP[0] = -1;
  for (int iT = 1; iT <= nT; iT++) {
    for (int k = KMP[iT - 1]; k != -1; k = KMP[k]) {
      if (T[k + 1] == T[iT]) {
        KMP[iT] = k + 1;
        break;
      }
    }
  }
  memset(Next, 0xff, sizeof(Next));
  for (int Char = 0; Char < 26; Char++) Next[0][Char] = 0;
  for (int iT = 1; iT <= nT; iT++) {
    Next[iT - 1][T[iT] - Shift] = iT;
  }
  for (int iT = 1; iT <= nT; iT++) {
    for (int Char = 0; Char < 26; Char++) {
      if (Next[iT][Char] == -1) Next[iT][Char] = Next[KMP[iT]][Char];
    }
  }
  F.resize(nS + 2);
  for (int iS = 0; iS <= nS + 1; iS++) {
    F[iS].resize(nT + 2);
  }
  for (int iS = 0; iS <= nS; iS++) {
    for (int iT = 0; iT <= nT; iT++) {
      F[iS][iT] = -oo;
    }
  }
  F[0][0] = 0;
  int res = 0;
  for (int iS = 0; iS < nS; iS++) {
    for (int preT = 0; preT <= nT; preT++) {
      if (S[iS + 1] == '?') {
        for (int Char = 0; Char < 26; Char++) {
          if (Next[preT][Char] != -1) {
            F[iS + 1][Next[preT][Char]] =
                max(F[iS + 1][Next[preT][Char]],
                    F[iS][preT] + (Next[preT][Char] == nT));
          }
        }
      } else {
        int Char = S[iS + 1] - Shift;
        if (Next[preT][Char] != -1) {
          F[iS + 1][Next[preT][Char]] =
              max(F[iS + 1][Next[preT][Char]],
                  F[iS][preT] + (Next[preT][Char] == nT));
        }
      }
    }
  }
  for (int iS = 0; iS <= nS; iS++) {
    for (int preT = 0; preT <= nT; preT++) {
      res = max(res, F[iS][preT]);
    }
  }
  cout << res;
  return 0;
}
