#include <bits/stdc++.h>
using namespace std;
int num_p[35], num_ss[35];
int main() {
  string ss;
  cin >> ss;
  string p;
  cin >> p;
  if (p.length() > ss.length()) {
    puts("0");
    return 0;
  }
  for (int i = 0; i < p.length(); i++) {
    num_p[p[i] - 'a']++;
    if (ss[i] != '?') num_ss[ss[i] - 'a']++;
  }
  int ans = 1;
  for (int i = 0; i < 26; i++)
    if (num_ss[i] > num_p[i]) {
      ans = 0;
      break;
    }
  for (int i = 1; i + (int)p.length() - 1 < (int)ss.length(); i++) {
    if (ss[i - 1] != '?') num_ss[ss[i - 1] - 'a']--;
    if (ss[i + (int)p.length() - 1] != '?')
      num_ss[ss[i + (int)p.length() - 1] - 'a']++;
    bool check = true;
    for (int j = 0; j < 26; j++)
      if (num_ss[j] > num_p[j]) {
        check = false;
        break;
      }
    ans += (int)check;
  }
  printf("%d\n", ans);
  return 0;
}
