#include <bits/stdc++.h>
using namespace std;
int cnt[50];
int curr[50];
char a[100010];
char b[100010];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> a >> b;
  int n = strlen(a);
  int m = strlen(b);
  if (n < m) {
    cout << 0 << '\n';
    return 0;
  }
  for (int i = 0; i < m; i++) {
    cnt[b[i] - 'a']++;
    if (a[i] != '?') curr[a[i] - 'a']++;
  }
  int ans = 0;
  bool ok;
  for (int i = m; i < n; i++) {
    ok = true;
    for (int j = 0; j < 26; j++) {
      if (curr[j] > cnt[j]) {
        ok = false;
        break;
      }
    }
    if (ok) ans++;
    if (a[i - m] != '?') curr[a[i - m] - 'a']--;
    if (a[i] != '?') curr[a[i] - 'a']++;
  }
  ok = true;
  for (int j = 0; j < 26; j++) {
    if (curr[j] > cnt[j]) {
      ok = false;
      break;
    }
  }
  if (ok) ans++;
  cout << ans << '\n';
  return 0;
}
