#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
char A[N];
char B[N];
int buck[128];
int ans[128];
bool ok() {
  for (int i = 'a'; i <= 'z'; ++i)
    if (buck[i] > ans[i]) return false;
  return true;
}
int main() {
  scanf("%s", A);
  scanf("%s", B);
  int aa = strlen(A);
  int bb = strlen(B);
  for (int i = 0; i < bb; ++i) {
    buck[A[i]]++;
    ans[B[i]]++;
  }
  int cnt = 0;
  for (int i = bb - 1; i < aa; ++i) {
    if (ok()) cnt++;
    buck[A[i - bb + 1]]--;
    buck[A[i + 1]]++;
  }
  printf("%d\n", cnt);
  return 0;
}
