// Problem: C. Anagram Search
// Contest: Codeforces - Codeforces Round 103 (Div. 2)
// URL: https://codeforces.com/contest/144/problem/C
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// Author: OrangeSummer
//
// Powered by CP Editor (https://cpeditor.org)
#include <bits/stdc++.h>
using namespace std;
#define IOS \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
// #define int long long
#define endl '\n'
#define STED(_x) _x.begin(), _x.end()
#define rep(_x, _y, _z) for (int _x = _y; _x < _z; _x++)
typedef long long i64;
typedef pair<int, int> pii;
const int N = 2e5 + 10;
// dont use umap!!!
void solve()
{
string s, t;
cin >> s >> t;
vector<int> cnt(26), vcnt(26);
int ans = 0;
for (auto i : t)
{
cnt[i - 'a']++;
}
for (int i = 0; i < s.size(); i++)
{
if (s[i] != '?')
vcnt[s[i] - 'a']++;
if (i >= t.size() && s[i - t.size()] != '?')
vcnt[s[i - t.size()] - 'a']--;
if (i >= t.size() - 1)
{
bool ok = 1;
for (int i = 0; i < 26; i++)
{
if (vcnt[i] > cnt[i])
{
ok = 0;
break;
}
}
ans += ok;
}
}
cout << ans << endl;
}
signed main()
{
int _ = 1;
// cin >> _;
while (_--)
solve();
return 0;
}
507B - Amr and Pins | 379A - New Year Candles |
1154A - Restoring Three Numbers | 750A - New Year and Hurry |
705A - Hulk | 492B - Vanya and Lanterns |
1374C - Move Brackets | 1476A - K-divisible Sum |
1333A - Little Artem | 432D - Prefixes and Suffixes |
486A - Calculating Function | 1373B - 01 Game |
1187A - Stickers and Toys | 313B - Ilya and Queries |
579A - Raising Bacteria | 723A - The New Year Meeting Friends |
302A - Eugeny and Array | 1638B - Odd Swap Sort |
1370C - Number Game | 1206B - Make Product Equal One |
131A - cAPS lOCK | 1635A - Min Or Sum |
474A - Keyboard | 1343A - Candies |
1343C - Alternating Subsequence | 1325A - EhAb AnD gCd |
746A - Compote | 318A - Even Odds |
550B - Preparing Olympiad | 939B - Hamster Farm |