#include <bits/stdc++.h>
using namespace std;
int val[100009][327];
int need[330];
int main() {
  int tc, cs = 1, i, j, k;
  int n, m;
  string str, tar;
  cin >> str;
  cin >> tar;
  int len = str.length();
  int len2 = tar.length();
  for (i = 0; i < tar.length(); i++) need[tar[i] - '?']++;
  val[0][str[0] - '?']++;
  for (i = 1; i < len; i++) {
    for (j = 30; j < 60; j++) val[i][j] = val[i - 1][j];
    val[i][str[i] - '?']++;
  }
  int res = 0;
  for (i = 0; i < len; i++) {
    if (i - len2 + 1 >= 0) {
      for (j = 30; j < 60; j++) {
        if (val[i][j] - val[i - len2][j] > need[j]) {
          break;
        }
      }
      if (j == 60) {
        res++;
      }
    }
  }
  cout << res << endl;
  return 0;
}
