#include <bits/stdc++.h>
const double Pi = acos(-1.0);
using namespace std;
string s, t;
int slen, tlen;
int total;
int occ[128];
int toccer[128];
int step;
bool check() {
  occ[(int)s[step]]--;
  step++;
  occ[(int)s[step + tlen - 1]]++;
  for (int i = 'a'; i <= 'z'; i++) {
    if (toccer[i] < occ[i]) return false;
  }
  return true;
}
int main(int argc, char** argv) {
  cin >> s >> t;
  slen = s.length();
  tlen = t.length();
  if (slen < tlen) {
    printf("0\n");
    return 0;
  }
  for (int i = 0; i < tlen; i++) {
    occ[(int)s[i]]++;
    toccer[(int)t[i]]++;
  }
  bool boxhead = true;
  for (int i = 'a'; i <= 'z'; i++) {
    if (toccer[i] < occ[i]) {
      boxhead = false;
      break;
    }
  }
  if (boxhead) total++;
  int diff = slen - tlen;
  for (int i = 0; i < diff; i++) {
    if (check()) {
      total++;
    }
  }
  printf("%d\n", total);
  return 0;
}
