#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = 2e6 + 55;
int vis[50];
char a[maxn];
char b[maxn];
int pre[maxn];
int visb[maxn];
int main(int argc, char *argv[]) {
  if (argc == 2 && strcmp("-debug", argv[1]) == 0) {
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
  }
  scanf("%s%s", a + 1, b + 1);
  int lena = strlen(a + 1), lenb = strlen(b + 1);
  if (lena < lenb) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 1; i <= lena; i++) pre[i] = pre[i - 1] + (a[i] == '?' ? 1 : 0);
  for (int i = 1; i < lenb; i++) vis[a[i] - 'a']++;
  for (int i = 1; i <= lenb; i++) visb[b[i] - 'a']++;
  int ans = 0;
  for (int i = lenb; i <= lena; i++) {
    if (a[i] != '?') {
      vis[a[i] - 'a']++;
    }
    if (a[i - lenb] != 0) vis[a[i - lenb] - 'a']--;
    int temp = 0;
    for (int j = 0; j <= 26; j++) {
      if (visb[j] - vis[j] >= 0) temp += visb[j] - vis[j];
    }
    if (temp == pre[i] - pre[i - lenb]) ans++;
  }
  cout << ans << endl;
  return 0;
}
