#include <bits/stdc++.h>
using namespace std;
const long long int N = 1e5 + 50;
const long long int mod = 1e9 + 9;
long long int cnt_a[26], cnt_b[26];
int main() {
  ios::sync_with_stdio(false);
  string a, b;
  cin >> a >> b;
  long long int x = a.length();
  long long int y = b.length();
  long long int ans = 0;
  if (y > x) {
    cout << "0\n";
    return 0;
  }
  for (long long int i = 0; i < y; i++) {
    cnt_b[b[i] - 'a']++;
  }
  long long int q = 0;
  for (long long int i = 0; i < y - 1; i++) {
    if (a[i] != '?') {
      cnt_a[a[i] - 'a']++;
      continue;
    }
    q++;
  }
  long long int i = y - 1;
  while (i < x) {
    if (a[i] == '?') {
      q++;
    } else {
      cnt_a[a[i] - 'a']++;
    }
    long long int temp = 0;
    bool flag = 0;
    for (long long int j = 0; j < 26; j++) {
      if (cnt_a[j] > cnt_b[j]) {
        flag = 1;
        break;
      }
      temp += cnt_b[j] - cnt_a[j];
    }
    if (!flag and temp == q) {
      ans++;
    }
    i++;
    if (a[i - y] == '?') {
      q--;
    } else {
      cnt_a[a[i - y] - 'a']--;
    }
  }
  cout << ans << endl;
  return 0;
}
