#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1E9 + 10;
const double EPS = 1E-9;
int usedS[30], usedP[30];
int main() {
  string s, p;
  cin >> s >> p;
  int lenS = s.size(), lenP = p.size(), cntC = 0, ans = 0;
  for (int i = 0; i < lenP; i++) usedP[p[i] - 'a']++;
  int S = 0;
  for (int i = 0; i < lenS; i++) {
    int ch = s[i] - 'a';
    if (s[i] == '?')
      cntC++;
    else {
      usedS[ch]++;
      cntC++;
      while (usedS[ch] > usedP[ch]) {
        if (s[S] != '?') usedS[s[S] - 'a']--;
        S++, cntC--;
      }
    }
    if (cntC == lenP) {
      if (s[S] != '?') usedS[s[S] - 'a']--;
      S++;
      ans++;
      cntC--;
    }
  }
  printf("%d\n", ans);
  return 0;
}
