#include <bits/stdc++.h>
using namespace std;
double pi = 3.141592653589793238462643383279L;
;
double eps = 1e-12;
int len;
int n;
int cnt[300];
int pos_s, neg_s, ask_cnt;
void shift(int pos, string& s) {
  if (s[pos] == '?')
    ask_cnt--;
  else if (cnt[s[pos]] <= 0)
    neg_s++;
  else if (cnt[s[pos]] > 0)
    pos_s--;
  cnt[s[pos]]--;
  pos += n;
  if (pos >= s.length()) return;
  if (s[pos] == '?') {
    ask_cnt++;
    return;
  }
  cnt[s[pos]]++;
  if (cnt[s[pos]] <= 0) neg_s--;
  if (cnt[s[pos]] > 0) pos_s++;
}
int main() {
  string s, p;
  cin >> s >> p;
  if (p.size() > s.size()) {
    cout << "0";
    return 0;
  }
  n = p.size();
  len = s.size();
  for (int i = 0; i < n; i++) cnt[p[i]]--;
  for (int i = 0; i < n; i++) {
    if (s[i] != '?')
      cnt[s[i]]++;
    else
      ask_cnt++;
  }
  for (int i = 0; i < 300; i++)
    if (cnt[i] > 0)
      pos_s += cnt[i];
    else
      neg_s -= cnt[i];
  int res = 0;
  for (int i = 0; i < len - n + 1; i++) {
    if (pos_s == 0 && neg_s == ask_cnt) res++;
    if (i < len - n) shift(i, s);
  }
  cout << res;
  return 0;
}
