#include <bits/stdc++.h>
using namespace std;
bool isequal(int h1[], int h2[]) {
  for (int i = 0; i <= 25; i++) {
    if (h1[i] > h2[i]) return false;
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s, p;
  cin >> s >> p;
  if (p.length() > s.length())
    cout << "0";
  else {
    int h1[26] = {0};
    int h2[26] = {0};
    for (int i = 0; i < p.length(); i++) h2[p[i] - 'a']++;
    for (int i = 0; i < p.length(); i++) {
      if (s[i] >= 'a' && s[i] <= 'z') h1[s[i] - 'a']++;
    }
    long long int cnt = 0;
    if (isequal(h1, h2)) cnt++;
    int j = 0;
    for (int i = p.length(); i < s.length(); i++) {
      if (s[i] >= 'a' && s[i] <= 'z') h1[s[i] - 'a']++;
      if (s[j] >= 'a' && s[j] <= 'z') h1[s[j] - 'a']--;
      if (isequal(h1, h2)) cnt++;
      j++;
    }
    cout << cnt;
  }
  return 0;
}
