#include <bits/stdc++.h>
using namespace std;
int alph[26];
int com[26];
int main() {
  string s, t;
  cin >> s >> t;
  int beg = 0, QM = 0, res = 0;
  for (int i = 0; i < t.size(); i++) alph[t[i] - 'a']++;
  for (int i = 0; i < 26; i++)
    if (alph[i] == 0) alph[i] = -1;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != '?')
      if (alph[s[i] - 'a'] == -1) {
        beg = i + 1;
        QM = 0;
        for (int j = 0; j < 26; j++) {
          if (alph[j] == -1) continue;
          com[j] = 0;
        }
        continue;
      }
    if (s[i] == '?')
      QM++;
    else
      com[s[i] - 'a']++;
    if (i - beg + 1 == t.size()) {
      int diff = 0;
      for (int j = 0; j < 26; j++) {
        if (alph[j] == -1) continue;
        if (com[j] > alph[j]) {
          diff = -1;
          break;
        }
        diff += (alph[j] - com[j]);
      }
      if (diff == -1) {
        if (s[beg] == '?')
          QM--;
        else
          com[s[beg] - 'a']--;
        beg++;
        continue;
      }
      if (diff == 0 && QM == 0)
        res++;
      else if (diff != 0 && QM == diff)
        res++;
      if (s[beg] == '?')
        QM--;
      else
        com[s[beg] - 'a']--;
      beg++;
    }
  }
  cout << res;
  return 0;
}
