#include <bits/stdc++.h>
using namespace std;
int a[26], b[27], ans, flag;
string s, p;
int main() {
  cin >> s >> p;
  for (int i = 0; i < (int)p.size(); i++) a[int(p[i]) - 97]++;
  if ((int)p.size() > (int)s.size()) {
    cout << 0 << endl;
    return 0;
  }
  for (int j = 0; j <= (int)p.size() - 1; j++) {
    if (s[j] == '?')
      b[26]++;
    else
      b[int(s[j]) - 97]++;
  }
  for (int j = 0; j < 26; j++) {
    if (b[j] > a[j])
      flag = 1;
    else
      b[26] -= (a[j] - b[j]);
  }
  if (!flag || b[26] >= 0) ans++;
  for (int i = 1; i <= (int)s.size() - (int)p.size(); i++) {
    flag = 0;
    if (s[i - 1] != '?')
      b[int(s[i - 1]) - 97]--;
    else if (s[i - 1] == '?')
      b[26]--;
    if (s[i + (int)p.size() - 1] != '?')
      b[int(s[i + (int)p.size() - 1]) - 97]++;
    else
      b[26]++;
    for (int j = 0; j < 26; j++) {
      if (b[j] > a[j])
        flag = 1;
      else
        b[26] -= a[j] - b[j];
    }
    if (!flag || b[26] >= 0) ans++;
  }
  cout << ans << endl;
  return 0;
}
