#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  string str;
  cin >> str;
  string p;
  cin >> p;
  if (p.size() > str.size()) {
    cout << 0 << '\n';
    return 0;
  }
  unordered_map<char, int> mp, tmp;
  for (int i = 0; i < p.size(); i++) mp[p[i]]++;
  int left = 0, right = 0;
  for (int i = 0; i < p.size(); i++) {
    tmp[str[i]]++;
    right++;
  }
  int tot = 0;
  while (right < str.size()) {
    int lagbe = 0;
    int ache = tmp['?'];
    int ok = 0;
    for (char i = 'a'; i <= 'z'; i++) {
      if (tmp[i] > mp[i]) {
        ok = 1;
        break;
      }
      lagbe += (mp[i] - tmp[i]);
    }
    if (!ok)
      if (lagbe == ache) tot++;
    tmp[str[left]]--;
    left++;
    if (right < str.size()) tmp[str[right]]++;
    right++;
  }
  int ache = tmp['?'];
  int lagbe = 0;
  int ok = 0;
  for (char i = 'a'; i <= 'z'; i++) {
    if (tmp[i] > mp[i]) {
      ok = 1;
      break;
    }
    lagbe += (mp[i] - tmp[i]);
  }
  if (!ok) {
    if (ache == lagbe) tot++;
  }
  cout << tot << '\n';
}
