#include <bits/stdc++.h>
using namespace std;
int modulo(int m, int n) { return m >= 0 ? m % n : (n - abs(m % n)) % n; }
bool compare(vector<int> a, vector<int> b) {
  int req = 0;
  for (int i = int(0); i < int(26); i++) {
    if (a[i] > b[i]) {
      return false;
    }
    if (a[i] <= b[i]) {
      req += b[i] - a[i];
    }
  }
  if (req == a[26])
    return true;
  else
    return false;
}
vector<int> compute(string a) {
  vector<int> ans(27, 0);
  for (int i = int(0); i < int(a.length()); i++) {
    if (a.at(i) == '?')
      ans[26]++;
    else {
      int f = a.at(i) - 97;
      ans[f]++;
    }
  }
  return ans;
}
int main() {
  string a = "", b = "";
  cin >> a;
  cin >> b;
  if (b.length() > a.length()) {
    cout << 0 << endl;
  } else {
    bool requ = false;
    int fi = a.length() - b.length();
    for (int i = int(0); i < int(a.length()); i++)
      if (a.at(i) != '?') requ = true;
    if (!requ)
      cout << fi + 1 << endl;
    else {
      vector<int> p = compute(b);
      int ans = 0;
      vector<int> fir = compute(a.substr(0, b.length()));
      for (int i = int(0); i <= int(fi - 1); i++) {
        if (compare(fir, p)) {
          ans++;
        }
        if (a.at(i) == '?')
          fir[26]--;
        else {
          int f = a.at(i) - 97;
          fir[f]--;
        }
        if (a.at(i + b.length()) == '?')
          fir[26]++;
        else {
          int f = a.at(i + b.length()) - 97;
          fir[f]++;
        }
      }
      if (compare(fir, p)) {
        ans++;
      }
      cout << ans << endl;
    }
  }
  return 0;
}
