#include <bits/stdc++.h>
using namespace std;
int main() {
  string s1, s2;
  long long int i, ans, dif, cq, p, j;
  cin >> s1 >> s2;
  vector<long long int> cnt(27, 0), cnt1(27, 0);
  for (i = 0; i < s2.length(); i++) {
    cnt[s2[i] - 97]++;
  }
  if (s2.length() > s1.length()) {
    cout << 0 << endl;
    exit(0);
  }
  cq = 0;
  for (i = 0; i < s2.length(); i++) {
    if (s1[i] == '?')
      cq = cq + 1;
    else
      cnt1[s1[i] - 97]++;
  }
  ans = 0;
  dif = 0;
  p = 0;
  for (i = 0; i <= 26; i++) {
    if (cnt[i] == 0 && cnt1[i] != 0) {
      p = 1;
      break;
    }
    dif = dif + abs(cnt1[i] - cnt[i]);
  }
  if (cq >= dif && p == 0) {
    ans = ans + 1;
  }
  for (i = 1; i + s2.length() <= s1.length(); i++) {
    if (s1[i - 1] == '?')
      cq = cq - 1;
    else
      cnt1[s1[i - 1] - 97]--;
    if (s1[i + s2.length() - 1] == '?')
      cq = cq + 1;
    else
      cnt1[s1[i + s2.length() - 1] - 97]++;
    dif = 0;
    p = 0;
    for (j = 0; j <= 26; j++) {
      if (cnt[j] == 0 && cnt1[j] != 0) {
        p = 1;
        break;
      }
      dif = dif + abs(cnt1[j] - cnt[j]);
    }
    if (cq >= dif && p == 0) {
      ans = ans + 1;
    }
  }
  cout << ans << endl;
}
