#include <bits/stdc++.h>
double const PI = 4 * atan(1.0);
using namespace std;
string s, p;
int n, m, f[30][100111] = {0}, so[555] = {0};
int main() {
  cin >> s >> p;
  m = p.length();
  n = s.length();
  for (int i = 0; i < m; i++) {
    so[p[i] - 'a']++;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= 'z' - 'a'; j++) {
      if (i == 0)
        f[j][i] = 0;
      else
        f[j][i] = f[j][i - 1];
    }
    if (s[i] != '?') f[s[i] - 'a'][i]++;
  }
  int num, kq = 0;
  for (int i = 0; i <= n - m; i++) {
    int check = 1;
    for (int j = 0; j <= 'z' - 'a'; j++) {
      if (i == 0)
        num = f[j][m - 1];
      else
        num = f[j][i + m - 1] - f[j][i - 1];
      if (num > so[j]) {
        check = 0;
        break;
      }
    }
    kq += check;
  }
  printf("%d\n", kq);
}
