#include <bits/stdc++.h>
using namespace std;
string s, p;
int ans = 0;
vector<int> counts(255), need(255);
bool enough() {
  int overflow = 0;
  for (int i = 0; i < 255; i++)
    if (counts[i] < need[i])
      overflow += need[i] - counts[i];
    else if (counts[i] > need[i] && i != '?')
      return false;
  if (overflow != counts['?']) return false;
  return true;
}
int main() {
  cin >> s >> p;
  for (int i = 0; i < p.size(); i++) need[p[i]]++;
  int j = 0;
  for (; j < p.size() && j < s.size(); j++) counts[s[j]]++;
  for (int i = 0; j <= s.size(); i++, j++) {
    ans += enough();
    if (i < s.size()) counts[s[i]]--;
    if (j < s.size()) counts[s[j]]++;
  }
  cout << ans;
  return 0;
}
