#include <bits/stdc++.h>
using namespace std;
char s[100001], p[100001];
int a[300], d[300];
int main() {
  gets(s);
  gets(p);
  int sz, sz_s;
  for (sz = 0; p[sz]; ++sz) d[p[sz]]++;
  sz_s = (int)strlen(s);
  if (sz > sz_s) {
    printf("0\n");
    return 0;
  }
  int cnt = 0, ans = 0;
  for (int i = 0; i < sz - 1; ++i) {
    if (s[i] == '?')
      cnt++;
    else
      a[s[i]]++;
  }
  for (int i = 0; i + sz - 1 < sz_s; i++) {
    int no = 0;
    if (s[i + sz - 1] == '?')
      cnt++;
    else
      a[s[i + sz - 1]]++;
    for (int j = 0; j < 300; ++j) {
      if (a[j] < d[j]) no += d[j] - a[j];
    }
    if (cnt >= no) ans++;
    if (s[i] == '?')
      cnt--;
    else
      a[s[i]]--;
  }
  printf("%d\n", ans);
  return 0;
}
