#include <bits/stdc++.h>
using namespace std;
int ha[30];
int hb[30];
int main() {
  string a, b;
  cin >> a >> b;
  int n = a.length();
  int m = b.length();
  if (m > n) {
    cout << "0" << endl;
    return 0;
  }
  for (int i = 0; i < m; i++) {
    hb[b[i] - 'a']++;
  }
  for (int i = 0; i < m; i++) {
    if (a[i] != '?') ha[a[i] - 'a']++;
  }
  int ans = 0;
  bool f = 0;
  for (int i = 0; i < 26; i++) {
    if (ha[i] <= hb[i])
      continue;
    else {
      f = 1;
      break;
    }
  }
  if (f == 0) {
    ans++;
  }
  for (int i = 1; i <= n - m; i++) {
    bool f = 0;
    if (a[i - 1] != '?') {
      ha[a[i - 1] - 'a']--;
    }
    if (a[i + m - 1] != '?') {
      ha[a[i + m - 1] - 'a']++;
    }
    f = 0;
    for (int i = 0; i < 26; i++) {
      if (ha[i] <= hb[i])
        continue;
      else {
        f = 1;
        break;
      }
    }
    if (f == 0) {
      ans++;
    }
  }
  cout << ans << endl;
}
