#include <bits/stdc++.h>
int ss[128], pp[128];
char s[100005], p[100005];
int lens, lenp, i, ans;
bool judge() {
  for (int i = 'a'; i <= 'z'; ++i)
    if (ss[i] > pp[i]) return false;
  return true;
}
int main() {
  while (scanf("%s%s", s, p) != EOF) {
    lens = strlen(s), lenp = strlen(p);
    for (ans = i = 0; i < 128; ++i) pp[i] = ss[i] = 0;
    for (i = 0; i < lenp; ++i) pp[p[i]]++, ss[s[i]]++;
    for (i = lenp - 1; i < lens; ++i) {
      if (judge()) ++ans;
      ss[s[i - lenp + 1]]--;
      ss[s[i + 1]]++;
    }
    printf("%d\n", ans);
  }
}
