#include <bits/stdc++.h>
using namespace std;
bool check_balance(int *a, int *b) {
  int i;
  for (i = 0; i < 26; ++i)
    if (b[i] > a[i]) {
      return false;
    }
  return true;
}
int main() {
  string s, p;
  cin >> s;
  cin >> p;
  int n, m, i, j, a[26] = {}, count = 0;
  n = s.length();
  m = p.length();
  if (n < m) {
    cout << count;
    return 0;
  }
  int b[26] = {};
  for (i = 0; i < m; ++i) {
    a[p[i] - 'a']++;
    if (s[i] != '?') b[s[i] - 'a']++;
  }
  if (check_balance(a, b)) count++;
  for (i = m; i < n; ++i) {
    if (s[i] != '?') b[s[i] - 'a']++;
    if (s[i - m] != '?') b[s[i - m] - 'a']--;
    if (check_balance(a, b)) {
      count++;
    }
  }
  cout << count;
  return 0;
}
