#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 5;
int bk[555], cnt[555], ans;
char s[MAX], p[MAX];
int main() {
  cin >> (s + 1);
  cin >> (p + 1);
  int len1 = strlen(s + 1);
  int len2 = strlen(p + 1);
  if (len2 > len1) {
    puts("0");
    return 0;
  }
  for (int i = 1; i <= len2; i++) bk[p[i]]++;
  int l = 1, r = len2;
  for (int i = l; i <= r - 1; i++) cnt[s[i]]++;
  while (r <= len1) {
    cnt[s[l - 1]]--;
    cnt[s[r]]++;
    int rest = 0, flag = 1;
    for (int i = 'a'; i <= 'z'; i++) {
      if (cnt[i] > bk[i]) {
        flag = 0;
        break;
      }
      if (cnt[i] < bk[i]) rest += bk[i] - cnt[i];
    }
    if (flag && rest == cnt['?']) ans++;
    l++, r++;
  }
  printf("%d\n", ans);
  return 0;
}
