#include <bits/stdc++.h>
using namespace std;
int toInt(string s) {
  int r = 0;
  istringstream sin(s);
  sin >> r;
  return r;
}
long long toInt64(string s) {
  long long r = 0;
  istringstream sin(s);
  sin >> r;
  return r;
}
double toDouble(string s) {
  double r = 0;
  istringstream sin(s);
  sin >> r;
  return r;
}
string toString(long long n) {
  string s, s1;
  while (n / 10 > 0) {
    s += (char)((n % 10) + 48);
    n /= 10;
  }
  s += (char)((n % 10) + 48);
  n /= 10;
  s1 = s;
  for (long long i = 0; i < s.length(); i++) s1[(s.length() - 1) - i] = s[i];
  return s1;
}
bool isUpperCase(char c) { return c >= 'A' && c <= 'Z'; }
bool isLowerCase(char c) { return c >= 'a' && c <= 'z'; }
bool isLetter(char c) { return c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z'; }
bool isDigit(char c) { return c >= '0' && c <= '9'; }
char toLowerCase(char c) { return (isUpperCase(c)) ? (c + 32) : c; }
char toUpperCase(char c) { return (isLowerCase(c)) ? (c - 32) : c; }
int charcount[30], char2count[30];
int main() {
  ios::sync_with_stdio(0);
  string s, p;
  cin >> s >> p;
  if (p.length() > s.length()) {
    cout << 0 << endl;
    return 0;
  }
  int sum = 0, tedadA = 0, tools = s.length(), toolp = p.length();
  for (long long i = 0; i < toolp; i++) charcount[p[i] - 97]++;
  for (int i = 0; i < toolp; i++) {
    if (s[i] == '?')
      tedadA++;
    else
      char2count[s[i] - 97]++;
  }
  for (int i = toolp; i <= tools; i++) {
    int bad = 0;
    bool f = true;
    for (int j = 0; j < 29; j++)
      if (charcount[j] != char2count[j]) {
        if (charcount[j] < char2count[j])
          bad = tedadA + 1;
        else
          bad += charcount[j] - char2count[j];
        if (bad > tedadA) {
          f = false;
          break;
        }
      }
    if (f) sum++;
    if (i < tools) {
      if (s[(i) - (toolp)] == '?')
        tedadA--;
      else
        char2count[s[(i)-toolp] - 97]--;
      if (s[i] == '?')
        tedadA++;
      else
        char2count[s[i] - 97]++;
    }
  }
  cout << sum << endl;
}
