#include <bits/stdc++.h>
using namespace std;
const int MX = 200009;
const long long inf = (1ll << 60);
string s, s1;
long long ans, sum;
int p[3000], a[3000];
int main() {
  cin >> s >> s1;
  int k = s1.size();
  int n = s.size();
  if (k > n) {
    puts("0");
    return 0;
  }
  for (int i = 0; i < k; i++) {
    a[s1[i]]++;
  }
  bool ok = 1;
  for (int i = 0; i < k && i < n; i++) {
    if (s[i] == '?')
      sum++;
    else
      p[s[i]]++;
    for (int j = 'a'; j <= 'z'; j++) {
      if (p[j] > a[j]) ok = 0;
    }
  }
  if (ok) ans = 1;
  int p1 = 0, p2 = k;
  while (p2 < n) {
    ok = 1;
    if (s[p1] != '?') p[s[p1]]--;
    if (s[p1] == '?') sum--;
    if (s[p2] == '?') sum++;
    if (s[p2] != '?') p[s[p2]]++;
    for (int i = 'a'; i <= 'z'; i++) {
      if (p[i] > a[i]) ok = 0;
    }
    p1++;
    p2++;
    if (!ok) continue;
    ans++;
  }
  cout << ans << endl;
}
