#include <bits/stdc++.h>
using namespace std;
unordered_map<char, long long> s, p;
bool check() {
  long long any = s['?'];
  long long sub = 0;
  for (auto it = p.begin(); it != p.end(); it++) {
    if (s[it->first] > p[it->first])
      return false;
    else if (s[it->first] < p[it->first])
      sub += (p[it->first] - s[it->first]);
  }
  if (any >= sub) return true;
  return false;
}
long long solve(string s1, string s2) {
  long long ans = 0;
  for (long long i = 0; i < s2.size(); i++) {
    s[s1[i]]++;
  }
  if (check()) ans++;
  long long start = 0;
  for (long long i = s2.size(); i < s1.size(); i++) {
    s[s1[start]]--;
    s[s1[i]]++;
    if (check()) ans++;
    start++;
  }
  return ans;
}
int main() {
  string s1, s2;
  cin >> s1 >> s2;
  for (long long i = 0; i < s2.length(); i++) p[s2[i]]++;
  if (s2.length() > s1.length())
    cout << "0\n";
  else
    cout << solve(s1, s2) << endl;
  return 0;
}
