#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <list>
#include <cstring>
using namespace std;

#define fr first
#define sd second
#define pb push_back
#define mp make_pair

typedef long long ll;
typedef vector < vector < double > > vvd;
typedef vector < double > vd;
typedef vector < pair < double, double> > vdd;
typedef vector < vector < long long > > vvl;
typedef vector < long long > vl;

int main()
{
	string sa, sb;
	cin >> sa;
	cin >> sb;
	int a[26], b[26];
	fill(a, a+26, 0);
	fill(b, b+26, 0);

	for(size_t i = 0; i < sb.size(); i++) {
		b[sb[i] - 'a']++;
		if(sa[i] != '?') {
			a[sa[i] - 'a']++;
		}
	}

	ll res = 0;
	ll cnt = 0;

	ll n = sb.size();

	for(int i = 0; i < 26; i++) {
		if(a[i] <= b[i]) {
			cnt++;
		}
	}

	if(cnt == 26) {
		res++;
	}

	for(size_t i = n; i < sa.size(); i++) {
		if(sa[i - n] != '?') {
			a[sa[i - n] - 'a']--;
		}

		if(sa[i] != '?') {
			a[sa[i] - 'a']++;
		}
		cnt = 0;
		for(int j = 0; j < 26; j++) {
			if(a[j] <= b[j]) {
				cnt++;
			}
		}

		if(cnt == 26) {
			res++;
		}
	}

	cout << res << endl;
	return 0;
}


//BISMILLAHIR RAHMANIR RAHIM
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<string>
#include<map>
#include<queue>
#include<vector>
#include<iostream>
using namespace std;
#define inf 1<<25
#define sz 100005
#define eps 1e-9
char ss[sz],pp[sz];
int op[200],os[200],lp,vp[200];
int anagram(int n,int ll)
{
    int i,t=0;
    memset(os,0,sizeof(os));
    for(i=n;i<=ll;i++)
        os[ss[i]]++;
    for(i='a';i<='z';i++)
    {
        if(os[i]<=op[i])
            continue;
        else
            return 0;
    }
    return 1;
}
int main()
{
    //    freopen("output.txt","w",stdout);
    //    freopen("input.txt","r",stdin);
    int i,j,p,l,ls,x,gs=0,q,k;
    scanf("%s %s",&ss,&pp);
    lp=strlen(pp);
    for(i=0;i<lp;i++)
    {
        op[pp[i]]++;
        vp[pp[i]]=1;
    }

    ls=strlen(ss);
            for(j=0;j<=ls-lp;j++)
            {
                q=anagram(j,j+lp-1);
                if(q==1)
                    gs++;
            }

    printf("%d\n",gs);

    return 0;
}


//BISMILLAHIR RAHMANIR RAHIM
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<string>
#include<map>
#include<queue>
#include<vector>
#include<iostream>
using namespace std;
#define inf 1<<25
#define sz 100005
#define eps 1e-9
char ss[sz],pp[sz];
int op[200],os[200],lp,vp[200];
int anagram(int n,int ll)
{
    int i,t=0;
    memset(os,0,sizeof(os));
    for(i=n;i<=ll;i++)
        os[ss[i]]++;
    for(i='a';i<='z';i++)
    {
        if(os[i]==op[i])
            continue;
        else if(os[i]>op[i])
            return 0;
        else
            t+=op[i]-os[i];
    }
    if(t!=os['?'])
        return 0;
    return 1;
}
int main()
{
    //    freopen("output.txt","w",stdout);
    //    freopen("input.txt","r",stdin);
    int i,j,p,l,ls,x,gs=0,q,k;
    scanf("%s %s",&ss,&pp);
    lp=strlen(pp);
    for(i=0;i<lp;i++)
    {
        op[pp[i]]++;
        vp[pp[i]]=1;
    }

    l=0;
    ls=strlen(ss);
    k=0;
    while(l<ls-1)
    {
        for(i=l;i<ls;i++)
        {
            if(ss[i]!='?'&&vp[ss[i]]==0)
            {
                l=i+1;
                x=i-1;
                break;
            }
            else if(i==ls-1)
            {
                x=i;
                l=ls-1;
            }

        }
        if(x>=lp-1)
        {
            for(j=k;j<=x-lp+1;j++)
            {
                q=anagram(j,j+lp-1);
                if(q==1)
                    gs++;
            }
            k=l;
        }

    }
    printf("%d\n",gs);

    return 0;
}


//BISMILLAHIR RAHMANIR RAHIM
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<string>
#include<map>
#include<queue>
#include<vector>
#include<iostream>
using namespace std;
#define inf 1<<25
#define sz 100005
#define eps 1e-9
char ss[sz],pp[sz];
int op[200],os[200],lp,vp[200];
int anagram(int n,int ll)
{
    int i,t=0;
    memset(os,0,sizeof(os));
    for(i=n;i<=ll;i++)
        os[ss[i]]++;
    for(i='a';i<='z';i++)
    {
        if(os[i]==op[i])
            continue;
        else if(os[i]>op[i])
            return 0;
        else
            t+=op[i]-os[i];
    }
    if(t!=os['?'])
        return 0;
    return 1;
}
int main()
{
    //    freopen("output.txt","w",stdout);
    //    freopen("input.txt","r",stdin);
    int i,j,p,l,ls,x,gs=0,q,k;
    scanf("%s %s",&ss,&pp);
    lp=strlen(pp);
    for(i=0;i<lp;i++)
    {
        op[pp[i]]++;
        vp[pp[i]]=1;
    }

    l=0;
    ls=strlen(ss);
    k=0;
    while(1)
    {
        for(i=l;i<ls;i++)
        {
            if(ss[i]!='?'&&vp[ss[i]]==0)
            {
                l=i+1;
                x=i-1;
                break;
            }
            else if(i==ls-1)
            {
                x=i;
                l=ls-1;
            }

        }
        if(x>=lp-1)
        {
            for(j=k;j<=x-lp+1;j++)
            {
                q=anagram(j,j+lp-1);
                if(q==1)
                    gs++;
            }
            k=l;
        }
        if(l>=ls-1)
            break;

    }
    printf("%d\n",gs);

    return 0;
}


//BISMILLAHIR RAHMANIR RAHIM
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<string>
#include<map>
#include<queue>
#include<vector>
#include<iostream>
using namespace std;
#define inf 1<<25
#define sz 100005
#define eps 1e-9
char ss[sz],pp[sz];
int op[200],os[200],lp,vp[200];
int main()
{
    //    freopen("output.txt","w",stdout);
    //    freopen("input.txt","r",stdin);
    int i,j,p,l,ls,x,gs=0,q,len=0;
    scanf("%s %s",&ss,&pp);
//    printf("%s\n%s\n",ss,pp);
    lp=strlen(pp);
    for(i=0;i<lp;i++)
    {
        op[pp[i]]++;
    }
    ls=strlen(ss);
    for(i=0,j=0;i<ls;i++)
    {
        if(ss[i]=='?')
        {
            len++;
        }
        else
        {
           os[ss[i]]++;
           len++;
           while(os[ss[i]]>op[ss[i]])
           {
               if(ss[j]!='?')
               os[ss[j]]--;
               len--;
               j++;
           }

        }
        if(len==lp)
        {
            gs++;
            if(ss[j]!='?')
                os[ss[j]]--;
            len--;
            j++;
        }
    }
    printf("%d\n",gs);

    return 0;
}


//BISMILLAHIR RAHMANIR RAHIM
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<string>
#include<map>
#include<queue>
#include<vector>
#include<iostream>
using namespace std;
#define inf 1<<25
#define sz 100005
#define eps 1e-9
char ss[sz],pp[sz];
int op[200],os[200],lp,vp[200];
int anagram(int n,int ll)
{
    int i,t=0;
    memset(os,0,sizeof(os));
    for(i=n;i<=ll;i++)
        os[ss[i]]++;
    for(i='a';i<='z';i++)
    {
        if(os[i]==op[i])
            continue;
        else if(os[i]>op[i])
            return 0;
        else
            t+=op[i]-os[i];
    }
    if(t!=os['?'])
        return 0;
    return 1;
}
int main()
{
    //    freopen("output.txt","w",stdout);
    //    freopen("input.txt","r",stdin);
    int i,j,p,l,ls,x,gs=0,q;
    scanf("%s %s",&ss,&pp);
    lp=strlen(pp);
    for(i=0;i<lp;i++)
    {
        op[pp[i]]++;
        vp[pp[i]]=1;
    }

    l=0;
    ls=strlen(ss);
    while(l<ls-1)
    {
        for(i=l;i<ls;i++)
        {
            if(ss[i]!='?'&&vp[ss[i]]==0)
            {
                l=i+1;
                x=i;
                break;
            }
            else if(i==ls-1)
            {
                x=i+1;
                l=ls-1;
            }

        }
        if(x>=lp-1)
        {
            for(j=0;j<=x-lp;j++)
            {
                q=anagram(j,j+lp-1);
                if(q==1)
                    gs++;
            }
        }

    }
    printf("%d\n",gs);

    return 0;
}


#include <iostream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <cstring>
#include <queue>
#include <map>
#include <vector>
#include <inttypes.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <deque>
#include <set>
#define MAX 100000
#define TOL 0.000001
using namespace std;
struct comp {
    bool operator()(const int& lhs, const int& rhs) const{
        return lhs > rhs;
        }
    };
struct comps {
    bool operator()(const string& lhs, const string& rhs) const{
        return lhs > rhs;
        }
    };
bool f(pair<int,int> a,pair<int,int> b){return a.first<b.first;}
double dis(int x1,int y1,int x2,int y2){return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));}
int main()
{
    //freopen("output2.out","r",stdin);
    char s[100005];
    char p[100005];
    int c=0;
    scanf("%s%s",s,p);
    map<char,int> m;
    map<char,int> mm;
    map<char,int> mmm;
    int pl = strlen(p);
    int sl = strlen(s);
    for(int i=0;i<pl;i++)
        {m[s[i]]++;mm[p[i]]++;}
    for(int i=0;i<=sl-pl;i++){
        bool f = true;
        for(map<char,int>::iterator it=m.begin();it!=m.end();it++)
            if(it->first=='?')continue;
            else if(it->second > mm[it->first])f = false;
        if(f)c++;
        m[s[i]]--;m[s[i+pl]]++;
        }
    cout << c;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <cstring>
#include <queue>
#include <map>
#include <vector>
#include <inttypes.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <deque>
#include <set>
#define MAX 100000
#define TOL 0.000001
using namespace std;
struct comp {
    bool operator()(const int& lhs, const int& rhs) const{
        return lhs > rhs;
        }
    };
struct comps {
    bool operator()(const string& lhs, const string& rhs) const{
        return lhs > rhs;
        }
    };
bool f(pair<int,int> a,pair<int,int> b){return a.first<b.first;}
double dis(int x1,int y1,int x2,int y2){return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));}
int main()
{
    //freopen("output2.out","r",stdin);
    char s[100005];
    char p[100005];
    int c=0;
    scanf("%s%s",s,p);
    map<char,int> m;
    int pl = strlen(p);
    int sl = strlen(s);
    if(pl > sl){cout << 0;return 0;}
    for(int i=0;i<pl;i++)
        m[s[i]]++;
    bool f = true;
    for(int i=0;i<pl;i++){
        if(!f)break;
        (m[p[i]]>0) ? m[p[i]]-- : ((m['?']>0) ? m['?']-- : f=false);
        }
    if(f)c++;
    f=true;
    m.clear();
    for(int i=0;i<pl;i++)
        m[s[i]]++;
    for(int i=0;i<sl-pl;i++){
        m[s[i]]--;m[s[pl+i]]++;
        for(int j=0;j<pl;j++){
            if(!f)break;
            (m[p[j]]>0) ? m[p[j]]-- : ((m['?']>0) ? m['?']-- : f=false);
        }
        if(f)c++;
        m.clear();
        for(int j=0;j<pl;j++)
            m[s[i+j+1]]++;
        f=true;
        }
    cout << c;

    return 0;
}


#include <iostream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <cstring>
#include <queue>
#include <map>
#include <vector>
#include <inttypes.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <deque>
#include <set>
#define MAX 100000
#define TOL 0.000001
using namespace std;
struct comp {
    bool operator()(const int& lhs, const int& rhs) const{
        return lhs > rhs;
        }
    };
struct comps {
    bool operator()(const string& lhs, const string& rhs) const{
        return lhs > rhs;
        }
    };
bool f(pair<int,int> a,pair<int,int> b){return a.first<b.first;}
struct node {
    int x,y,r;
    }rad[1000];
double dis(int x1,int y1,int x2,int y2){return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));}
int main()
{
    //freopen("output2.out","r",stdin);
    char s[100005];
    char p[100005];
    int c=0;
    scanf("%s%s",s,p);
    map<char,int> m;
    int pl = strlen(p);
    int sl = strlen(s);
    for(int i=0;i<pl;i++)
        m[s[i]]++;
    bool f = true;
    for(int i=0;i<pl;i++){
        (m[p[i]]>0) ? m[p[i]]-- : ((m['?']>0) ? m['?']-- : f=false);
        }
    if(f)c++;
    f=true;
    m.clear();
    for(int i=0;i<pl;i++)
        m[s[i]]++;
    for(int i=0;i<sl-pl;i++){
        m[s[i]]--;m[s[pl+i]]++;
        for(int j=0;j<pl;j++){
            (m[p[j]]>0) ? m[p[j]]-- : ((m['?']>0) ? m['?']-- : f=false);
        }
        if(f)c++;
        m.clear();
        for(int j=0;j<pl;j++)
            m[s[i+j+1]]++;
        f=true;
        }
    cout << c;

    return 0;
}


#include <iostream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <cstring>
#include <queue>
#include <map>
#include <vector>
#include <inttypes.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <deque>
#include <set>
#define MAX 100000
#define TOL 0.000001
using namespace std;
struct comp {
    bool operator()(const int& lhs, const int& rhs) const{
        return lhs > rhs;
        }
    };
struct comps {
    bool operator()(const string& lhs, const string& rhs) const{
        return lhs > rhs;
        }
    };
bool f(pair<int,int> a,pair<int,int> b){return a.first<b.first;}
struct node {
    int x,y,r;
    }rad[1000];
double dis(int x1,int y1,int x2,int y2){return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));}
int main()
{
    string s,p;
    int c=0;
    cin >> s;
    cin >> p;
    map<char,int> m;
    int pl = p.length();
    int sl = s.length();
    for(int i=0;i<pl;i++)
        m[s[i]]++;
    bool f = true;
    for(int i=0;i<pl;i++){
        (m[p[i]]>0) ? m[p[i]]-- : ((m['?']>0) ? m['?']-- : f=false);
        }
    if(f)c++;
    f=true;
    m.clear();
    for(int i=0;i<pl;i++)
        m[s[i]]++;
    for(int i=0;i<=sl-pl;i++){
        m[s[i]]--;m[s[pl+i]]++;
        for(int j=0;j<pl;j++){
            (m[p[j]]>0) ? m[p[j]]-- : ((m['?']>0) ? m['?']-- : f=false);
        }
        if(f)c++;
        m.clear();
        for(int j=0;j<pl;j++)
            m[s[i+j+1]]++;
        f=true;
        }
    cout << c;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <cstring>
#include <queue>
#include <map>
#include <vector>
#include <inttypes.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <deque>
#include <set>
#define MAX 100000
#define TOL 0.000001
using namespace std;
struct comp {
    bool operator()(const int& lhs, const int& rhs) const{
        return lhs > rhs;
        }
    };
struct comps {
    bool operator()(const string& lhs, const string& rhs) const{
        return lhs > rhs;
        }
    };
bool f(pair<int,int> a,pair<int,int> b){return a.first<b.first;}
double dis(int x1,int y1,int x2,int y2){return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));}
int main()
{
    char s[100005];
    char p[100005];
    int c=0;
    scanf("%s%s",s,p);
    map<char,int> m;
    int pl = strlen(p);
    int sl = strlen(s);
    if(pl > sl){cout << 0;return 0;}
    for(int i=0;i<sl;i++)
        m[s[i]]++;
    if(m['?']==sl){cout << sl-pl+1;return 0;}
    m.clear();
    for(int i=0;i<pl;i++)
        m[s[i]]++;
    bool f = true;
    for(int i=0;i<pl;i++){
        if(!f)break;
        (m[p[i]]>0) ? m[p[i]]-- : ((m['?']>0) ? m['?']-- : f=false);
        }
    if(f)c++;
    f=true;
    m.clear();
    for(int i=0;i<pl;i++)
        m[s[i]]++;
    for(int i=0;i<sl-pl;i++){
        m[s[i]]--;m[s[pl+i]]++;
        for(int j=0;j<pl;j++){
            if(!f)break;
            (m[p[j]]>0) ? m[p[j]]-- : ((m['?']>0) ? m['?']-- : f=false);
        }
        if(f)c++;
        m.clear();
        for(int j=0;j<pl;j++)
            m[s[i+j+1]]++;
        f=true;
        }
    cout << c;

    return 0;
}


#include <iostream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <cstring>
#include <queue>
#include <map>
#include <vector>
#include <inttypes.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <deque>
#include <set>
#define MAX 100000
#define TOL 0.000001
using namespace std;
struct comp {
    bool operator()(const int& lhs, const int& rhs) const{
        return lhs > rhs;
        }
    };
struct comps {
    bool operator()(const string& lhs, const string& rhs) const{
        return lhs > rhs;
        }
    };
bool f(pair<int,int> a,pair<int,int> b){return a.first<b.first;}
struct node {
    int x,y,r;
    }rad[1000];
double dis(int x1,int y1,int x2,int y2){return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));}
int main()
{
    string s,p;
    int c=0;
    cin >> s;
    cin >> p;
    map<char,int> m;
    int pl = p.length();
    int sl = s.length();
    for(int i=0;i<pl;i++)
        m[s[i]]++;
    bool f = true;
    for(int i=0;i<pl;i++){
        (m[p[i]]>0) ? m[p[i]]-- : ((m['?']>0) ? m['?']-- : f=false);
        }
    if(f)c++;
    f=true;
    m.clear();
    for(int i=0;i<pl;i++)
        m[s[i]]++;
    for(int i=0;i<sl-pl;i++){
        m[s[i]]--;m[s[pl+i]]++;
        for(int j=0;j<pl;j++){
            (m[p[j]]>0) ? m[p[j]]-- : ((m['?']>0) ? m['?']-- : f=false);
        }
        if(f)c++;
        m.clear();
        for(int j=0;j<pl;j++)
            m[s[i+j+1]]++;
        f=true;
        }
    cout << c;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <cstring>
#include <queue>
#include <map>
#include <vector>
#include <inttypes.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <deque>
#include <set>
#define MAX 100000
#define TOL 0.000001
using namespace std;
struct comp {
    bool operator()(const int& lhs, const int& rhs) const{
        return lhs > rhs;
        }
    };
struct comps {
    bool operator()(const string& lhs, const string& rhs) const{
        return lhs > rhs;
        }
    };
bool f(pair<int,int> a,pair<int,int> b){return a.first<b.first;}
double dis(int x1,int y1,int x2,int y2){return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));}
int main()
{
    char s[100005];
    char p[100005];
    int c=0;
    scanf("%s%s",s,p);
    map<char,int> m;
    int pl = strlen(p);
    int sl = strlen(s);
    if(pl > sl){cout << 0;return 0;}
    for(int i=0;i<sl;i++)
        m[s[i]]++;
    if(m['?']==sl){cout << sl-pl+1;return 0;}
    for(int i=0;i<pl;i++)
        m[s[i]]++;
    bool f = true;
    for(int i=0;i<pl;i++){
        if(!f)break;
        (m[p[i]]>0) ? m[p[i]]-- : ((m['?']>0) ? m['?']-- : f=false);
        }
    if(f)c++;
    f=true;
    m.clear();
    for(int i=0;i<pl;i++)
        m[s[i]]++;
    for(int i=0;i<sl-pl;i++){
        m[s[i]]--;m[s[pl+i]]++;
        for(int j=0;j<pl;j++){
            if(!f)break;
            (m[p[j]]>0) ? m[p[j]]-- : ((m['?']>0) ? m['?']-- : f=false);
        }
        if(f)c++;
        m.clear();
        for(int j=0;j<pl;j++)
            m[s[i+j+1]]++;
        f=true;
        }
    cout << c;

    return 0;
}


#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
char a[111111],b[111111];
int s[333],s2[333];

void Get(char *a,int *s,int len)
{
    for(int i=0;i<len;i++) s[a[i]]++;
}

bool Judge()
{
    int suma=0;
    int sumb=0;
    for(int i='a';i<='z';i++)
    {
        if(s[i]>s2[i]) return false;
        suma+=s[i];
        sumb+=s2[i];
    }
    return 1;
}

int main()
{
    scanf("%s%s",a,b);
    int lena=strlen(a);
    int lenb=strlen(b);
//  if(lenb>lena)
//  {
//      cout<<0<<endl;
//      return 0;
//  }
//  else
//  {
        int ans=0;
        Get(a,s,lenb);
        Get(b,s2,lenb);
        int p=0;
        for(int i=lenb-1;i<lena;i++)
        {
            ans+=Judge();
            s[a[p]]--;
            s[a[i+1]]++;
            p++;
        }
        cout<<ans<<endl;
//  }
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
char a[111111],b[111111];
int s[333],s2[333];

void Get(char *a,int *s,int len)
{
	for(int i=0;i<len;i++) s[a[i]]++;
}

bool Judge()
{
	int suma=0;
	int sumb=0;
	for(int i='a';i<'z';i++)
	{
		if(s[i]>s2[i]) return false;
		suma+=s[i];
		sumb+=s2[i];
	}
	return suma+s['?']==sumb;
}

int main()
{
	scanf("%s%s",&a,&b);
	int lena=strlen(a);
	int lenb=strlen(b);
	if(lenb>lena)
	{
		cout<<0<<endl;
		return 0;
	}
	else
	{
		int ans=0;
		Get(a,s,lenb);
		Get(b,s2,lenb);
		int p=0;
		for(int i=lenb-1;i<lena;i++)
		{
			ans+=Judge();
			s[a[p]]--;
			s[a[i+1]]++;
			p++;
		}
		cout<<ans<<endl;
	}
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
char a[111111],b[111111];
int s[333],s2[333];

void Get(char *a,int *s,int len)
{
    for(int i=0;i<len;i++) s[a[i]]++;
}

bool Judge()
{
    int suma=0;
    int sumb=0;
    for(int i='a';i<'z';i++)
    {
        if(s[i]>s2[i]) return false;
        suma+=s[i];
        sumb+=s2[i];
    }
    return suma+s['?']==sumb;
}

int main()
{
    scanf("%s%s",a,b);
    int lena=strlen(a);
    int lenb=strlen(b);
//  if(lenb>lena)
//  {
//      cout<<0<<endl;
//      return 0;
//  }
//  else
//  {
        int ans=0;
        Get(a,s,lenb);
        Get(b,s2,lenb);
        int p=0;
        for(int i=lenb-1;i<lena;i++)
        {
            ans+=Judge();
            s[a[p]]--;
            s[a[i+1]]++;
            p++;
        }
        cout<<ans<<endl;
//  }
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
char a[111111],b[111111];
int s[333],s2[333];

void Get(char *a,int *s,int len)
{
    for(int i=0;i<len;i++) s[a[i]]++;
}

bool Judge()
{
    int suma=0;
    int sumb=0;
    for(int i='a';i<'z';i++)
    {
        if(s[i]>s2[i]) return false;
        suma+=s[i];
        sumb+=s2[i];
    }
    return 1;
}

int main()
{
    scanf("%s%s",a,b);
    int lena=strlen(a);
    int lenb=strlen(b);
//  if(lenb>lena)
//  {
//      cout<<0<<endl;
//      return 0;
//  }
//  else
//  {
        int ans=0;
        Get(a,s,lenb);
        Get(b,s2,lenb);
        int p=0;
        for(int i=lenb-1;i<lena;i++)
        {
            ans+=Judge();
            s[a[p]]--;
            s[a[i+1]]++;
            p++;
        }
        cout<<ans<<endl;
//  }
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
char a[111111],b[111111];
int s[333],s2[333];

void Get(char *a,int *s,int len)
{
    for(int i=0;i<len;i++) s[a[i]]++;
}

bool Judge()
{
    int suma=0;
    int sumb=0;
    for(int i='a';i<'z';i++)
    {
        if(s[i]>s2[i]) return false;
        suma+=s[i];
        sumb+=s2[i];
    }
    return suma+s['?']==sumb;
}

int main()
{
    scanf("%s%s",&a,&b);
    int lena=strlen(a);
    int lenb=strlen(b);
    if(lenb>lena)
    {
        cout<<0<<endl;
        return 0;
    }
    else
    {
        int ans=0;
        Get(a,s,lenb);
        Get(b,s2,lenb);
        int p=0;
        for(int i=lenb-1;i<lena;i++)
        {
            ans+=Judge();
            s[a[p]]--;
            s[a[i+1]]++;
            p++;
        }
        cout<<ans<<endl;
    }
    return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <sstream>
#include <string.h>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int, int>	ii;
typedef vector<ii>	vii;
typedef queue<int> qi;

#define INF 2000000000
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define REPE(i,a,b) for(int i=int(a);i<=int(b);i++)
#define mems(val)	memset(val,0,sizeof(val))
#define pb push_back

int modulo (int m, int n) { return m >= 0 ? m % n : ( n - abs ( m%n ) ) % n; }

bool compare(string a,vector<int> b)
{
	int req=0;
	REP(i,0,a.length())
	{
		int f = a.at(i)-97;
		if(f<0)
			req++;
		else if(b[f]>0)
			b[f]--;

	}
	REP(i,0,26)
	req -= b[i];
	if (req == 0)
		return true;
	else
		return false;
}

vector<int> compute(string a)
{
	vector<int> ans(26,0);
	REP(i,0,a.length())
	{
		int f = a.at(i)-97;
		ans[f]++;
	}
	return ans;
}

int main()
{
	string a="",b="";
	cin>>a;
	cin>>b;
	bool requ = false;
	int fi = a.length()-b.length();
	REP(i,0,a.length())
		if (a.at(i)!='?')
			requ = true;
	if(!requ)
		cout << fi+1 <<endl;
	else
	{
	vector<int> p = compute(b);
	int ans=0;
	REPE(i,0,fi)
	{
		string g = a.substr(i,b.length());
		if (compare(g,p))
		{
			ans++;
		}
	}
	cout << ans<<endl;
	}

	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <sstream>
#include <string.h>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int, int>	ii;
typedef vector<ii>	vii;
typedef queue<int> qi;

#define INF 2000000000
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define REPE(i,a,b) for(int i=int(a);i<=int(b);i++)
#define mems(val)	memset(val,0,sizeof(val))
#define pb push_back

int modulo (int m, int n) { return m >= 0 ? m % n : ( n - abs ( m%n ) ) % n; }

bool compare(string a,vector<int> b)
{
	int req=0;
	REP(i,0,a.length())
	{
		int f = a.at(i)-97;
		if(f<0)
			req++;
		else if(b[f]>0)
			b[f]--;

	}
	REP(i,0,26)
	req -= b[i];
	if (req == 0)
		return true;
	else
		return false;
}

vector<int> compute(string a)
{
	vector<int> ans(26,0);
	REP(i,0,a.length())
	{
		int f = a.at(i)-97;
		ans[f]++;
	}
	return ans;
}

int main()
{
	string a="",b="";
	cin>>a;
	cin>>b;
	vector<int> p = compute(b);
	int fi = a.length()-b.length();
	int ans=0;
	REPE(i,0,fi)
	{
		string g = a.substr(i,b.length());
		if (compare(g,p))
		{
			ans++;
		}
	}
	cout << ans<<endl;

	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <sstream>
#include <string.h>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int, int>	ii;
typedef vector<ii>	vii;
typedef queue<int> qi;

#define INF 2000000000
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define REPE(i,a,b) for(int i=int(a);i<=int(b);i++)
#define mems(val)	memset(val,0,sizeof(val))
#define pb push_back

int modulo (int m, int n) { return m >= 0 ? m % n : ( n - abs ( m%n ) ) % n; }

bool compare(string a,map<char,int> b)
{
	int req=0;
	REP(i,0,a.length())
	{
		if (b.count(a.at(i))>0)
		{
			if(b[a.at(i)]>0)
				b[a.at(i)]--;
		}
		else if(a.at(i)=='?')
			req++;
	}
	map<char,int>::iterator it;
	for (it=b.begin();it != b.end();it++)
		req -= (*it).second;
	if (req == 0)
		return true;
	else
		return false;
}

map<char,int> compute(string a)
{
	map<char,int> ans;
	REP(i,0,a.length())
	{
		ans[a.at(i)]++;
	}
	return ans;
}

int main()
{
	string a="",b="";
	cin>>a;
	cin>>b;
	map<char,int> p = compute(b);
	int fi = a.length()-b.length();
	int ans=0;
	REPE(i,0,fi)
	{
		string g = a.substr(i,b.length());
		if (compare(g,p))
		{
			ans++;
		}
	}
	cout << ans<<endl;

	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <sstream>
#include <string.h>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int, int>	ii;
typedef vector<ii>	vii;
typedef queue<int> qi;

#define INF 2000000000
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define REPE(i,a,b) for(int i=int(a);i<=int(b);i++)
#define mems(val)	memset(val,0,sizeof(val))
#define pb push_back

int modulo (int m, int n) { return m >= 0 ? m % n : ( n - abs ( m%n ) ) % n; }

bool compare(string a,vector<int> b,string p)
{
	bool requ = false;
	REP(i,0,a.length())
	if (a.at(i)=='?')
		requ = true;
	if(!requ)
	{	if (a == p)
			return true;
		else
			return false;
	}
	else
	{
	int req=0;
	REP(i,0,a.length())
	{
		int f = a.at(i)-97;
		if(f<0)
			req++;
		else if(b[f]>0)
			b[f]--;

	}
	REP(i,0,26)
	req -= b[i];
	if (req == 0)
		return true;
	else
		return false;
	}
}

vector<int> compute(string a)
{
	vector<int> ans(26,0);
	REP(i,0,a.length())
	{
		int f = a.at(i)-97;
		ans[f]++;
	}
	return ans;
}

int main()
{
	string a="",b="";
	cin>>a;
	cin>>b;
	bool requ = false;
	int fi = a.length()-b.length();
	REP(i,0,a.length())
		if (a.at(i)!='?')
			requ = true;
	if(!requ)
		cout << fi+1 <<endl;
	else
	{
	vector<int> p = compute(b);
	int ans=0;
	REPE(i,0,fi)
	{
		string g = a.substr(i,b.length());
		if (compare(g,p,b))
		{
			ans++;
		}
	}
	cout << ans<<endl;
	}

	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <sstream>
#include <string.h>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int, int>	ii;
typedef vector<ii>	vii;
typedef queue<int> qi;

#define INF 2000000000
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define REPE(i,a,b) for(int i=int(a);i<=int(b);i++)
#define mems(val)	memset(val,0,sizeof(val))
#define pb push_back

int modulo (int m, int n) { return m >= 0 ? m % n : ( n - abs ( m%n ) ) % n; }

bool compare(string a,vector<int> b,string p)
{
	bool requ = false;
	REP(i,0,a.length())
	if (a.at(i)=='?')
		requ = true;
	if(!requ)
	{
		sort(a.begin(),a.end());
		sort(p.begin(),p.end());
		if (a == p)
			return true;
		else
			return false;
	}
	else
	{
	int req=0;
	REP(i,0,a.length())
	{
		int f = a.at(i)-97;
		if(f<0)
			req++;
		else if(b[f]>0)
			b[f]--;

	}
	REP(i,0,26)
	req -= b[i];
	if (req == 0)
		return true;
	else
		return false;
	}
}

vector<int> compute(string a)
{
	vector<int> ans(26,0);
	REP(i,0,a.length())
	{
		int f = a.at(i)-97;
		ans[f]++;
	}
	return ans;
}

int main()
{
	string a="",b="";
	cin>>a;
	cin>>b;
	bool requ = false;
	int fi = a.length()-b.length();
	REP(i,0,a.length())
		if (a.at(i)!='?')
			requ = true;
	if(!requ)
		cout << fi+1 <<endl;
	else
	{
	vector<int> p = compute(b);
	int ans=0;
	REPE(i,0,fi)
	{
		string g = a.substr(i,b.length());
		if (compare(g,p,b))
		{
			ans++;
		}
	}
	cout << ans<<endl;
	}

	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <sstream>
#include <string.h>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int, int>	ii;
typedef vector<ii>	vii;
typedef queue<int> qi;

#define INF 2000000000
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define REPE(i,a,b) for(int i=int(a);i<=int(b);i++)
#define mems(val)	memset(val,0,sizeof(val))
#define pb push_back

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;

	REP(i,0,26)
	{
		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);
	REP(i,0,a.length())
	{
		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();
	REP(i,0,a.length())
		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()));
		REPE(i,0,fi-1)
		{
			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;
}


#include "stdafx.h"
#include <iostream>

using namespace std;
char ca[100002];
char ca2[100002];
int ia[27];
int ia2[27];
int main(){
    cin>>ca>>ca2;
    int l = strlen(ca2);
    for(int i = 0; i < l; i++)
        if(ca2[i]!='?')
            ia[ca2[i]-'a']++;
    for(int i = 0; i < l; i++)
        if(ca[i]!='?')
            ia2[ca[i]-'a']++;
    int count = 0;
    for(int i = l; i < strlen(ca); i++){
        for(int j = 0; j < 26; j++){
            if(ia[j] < ia2[j])break;
            if(j == 25) count++;
        }
        if(ca[i]!='?')
            ia2[ca[i]-'a']++;
        if(ca[i-l]!='?')
            ia2[ca[i-l]-'a']--;
    }
    for(int j = 0; j < 26; j++){
        if(ia[j] < ia2[j])break;
        if(j == 25) count++;
    }
    cout<<count<<"\n";
}


#include <iostream>
#include <cstring>

using namespace std;
char ca[100002];
char ca2[100002];
int ia[27];
int ia2[27];
int main(){
    cin>>ca>>ca2;
    if (strlen(ca) < strlen(ca2)) {
        cout << 0 << endl;
        return 0;
    }
    int l = strlen(ca2);
    for(int i = 0; i < l; i++)
        if(ca2[i]!='?')
            ia[ca2[i]-'a']++;
    for(int i = 0; i < l; i++)
        if(ca[i]!='?')
            ia2[ca[i]-'a']++;
    int count = 0;
    for(int i = l; i < strlen(ca); i++){
        for(int j = 0; j < 26; j++){
            if(ia[j] < ia2[j])break;
            if(j == 25) count++;
        }
        if(ca[i]!='?')
            ia2[ca[i]-'a']++;
        if(ca[i-l]!='?')
            ia2[ca[i-l]-'a']--;
    }
    for(int j = 0; j < 26; j++){
        if(ia[j] < ia2[j])break;
        if(j == 25) count++;
    }
    cout<<count<<"\n";
}


#include "stdafx.h"
#include <iostream>

using namespace std;
char ca[100002];
char ca2[100002];
int ia[27];
int ia2[27];
int main(){
    cin>>ca>>ca2;
    int l = strlen(ca2);
    for(int i = 0; i < l; i++)
        if(ca2[i]!='?')
            ia[ca2[i]-'a']++;
    for(int i = 0; i < l; i++)
        if(ca[i]!='?')
            ia2[ca[i]-'a']++;
    int cnt = 0;
    for(int i = l; i < strlen(ca); i++){
        for(int j = 0; j < 26; j++){
            if(ia[j] < ia2[j])break;
            if(j == 25) cnt++;
        }
        if(ca[i]!='?')
            ia2[ca[i]-'a']++;
        if(ca[i-l]!='?')
            ia2[ca[i-l]-'a']--;
    }
    for(int j = 0; j < 26; j++){
        if(ia[j] < ia2[j])break;
        if(j == 25) cnt++;
    }
    cout<<cnt<<"\n";
}


#include <iostream>
#include <cstring>

using namespace std;
char ca[100002];
char ca2[100002];
int ia[27];
int ia2[27];
int main(){
    cin>>ca>>ca2;
    int l = strlen(ca2);
    for(int i = 0; i < l; i++)
        if(ca2[i]!='?')
            ia[ca2[i]-'a']++;
    for(int i = 0; i < l; i++)
        if(ca[i]!='?')
            ia2[ca[i]-'a']++;
    int count = 0;
    for(int i = l; i < strlen(ca); i++){
        for(int j = 0; j < 26; j++){
            if(ia[j] < ia2[j])break;
            if(j == 25) count++;
        }
        if(ca[i]!='?')
            ia2[ca[i]-'a']++;
        if(ca[i-l]!='?')
            ia2[ca[i-l]-'a']--;
    }
    for(int j = 0; j < 26; j++){
        if(ia[j] < ia2[j])break;
        if(j == 25) count++;
    }
    cout<<count<<"\n";
}


#include <iostream>

using namespace std;
char ca[100002];
char ca2[100002];
int ia[27];
int ia2[27];
int main(){
    cin>>ca>>ca2;
    int l = strlen(ca2);
    for(int i = 0; i < l; i++)
        if(ca2[i]!='?')
            ia[ca2[i]-'a']++;
    for(int i = 0; i < l; i++)
        if(ca[i]!='?')
            ia2[ca[i]-'a']++;
    int count = 0;
    for(int i = l; i < strlen(ca); i++){
        for(int j = 0; j < 26; j++){
            if(ia[j] < ia2[j])break;
            if(j == 25) count++;
        }
        if(ca[i]!='?')
            ia2[ca[i]-'a']++;
        if(ca[i-l]!='?')
            ia2[ca[i-l]-'a']--;
    }
    for(int j = 0; j < 26; j++){
        if(ia[j] < ia2[j])break;
        if(j == 25) count++;
    }
    cout<<count<<"\n";
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <queue>
#include <stack>

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long int
using namespace std;
int const INF = (1<<29);
int const MAXN = (int)1e5+100;

string s,p;
set <string> red;

bool analogy(string t){
	int a[30];
	for (int i=0;i<30;i++)
		a[i] = 0;
	int cnt = 0;

	for (int i=0;i<p.length();i++){
		a[p[i]-'a']++;
	}
	for (int i=0;i<t.length();i++){
		if (t[i] == '?'){
			cnt++;
			continue;
		}
		a[t[i]-'a']--;
		if (a[t[i]-'a']<0){
			return false;
		}
	}

	int sum = 0;
	for (int i=0;i<26;i++){
		sum += a[i];
	}
	if (sum == cnt){
		return true;
	}
	return false;
}

int main (){
	//freopen ("input.txt","r",stdin);
	//freopen ("output.txt","w",stdout);
	getline(cin,s);
	getline(cin,p);
	if (p.length()>s.length()){
		cout <<0;
		return 0;
	}
	for (int i=0;i<=s.length()-p.length();i++){
		string tt = s.substr(i,p.length());
		if ( analogy(tt)   ){
			red.insert(tt);
		}
	}
	cout <<red.size();
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <queue>
#include <stack>

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long int
using namespace std;
int const INF = (1<<29);
int const MAXN = (int)1e5+100;

string s,p;
set <string> red;

bool analogy(string t){
	int a[26];
	for (int i=0;i<26;i++)
		a[i] = 0;
	int cnt = 0;

	for (int i=0;i<p.length();i++){
		a[p[i]-'a']++;
	}
	for (int i=0;i<t.length();i++){
		if (t[i] == '?'){
			cnt++;
			continue;
		}
		a[t[i]-'a']--;
		if (a[t[i]-'a']<0){
			return false;
		}
	}

	int sum = 0;
	for (int i=0;i<26;i++){
		sum += a[i];
	}
	if (sum == cnt){
		return true;
	}
	return false;
}

int main (){
	//freopen ("input.txt","r",stdin);
	//freopen ("output.txt","w",stdout);
	cin >>s;
	cin >>p;
	for (int i=0;i<=s.length()-p.length();i++){
		string tt = s.substr(i,p.length());
		if ( analogy(tt)   ){
			red.insert(tt);
		}
		cout <<tt<<endl;
	}
	cout <<red.size();
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <queue>
#include <stack>

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long int
using namespace std;
int const INF = (1<<29);
int const MAXN = (int)1e5+100;

string s,p;
set <string> red;

bool analogy(string t){
	int a[30];
	for (int i=0;i<30;i++)
		a[i] = 0;
	int cnt = 0;

	for (int i=0;i<p.length();i++){
		a[p[i]-'a']++;
	}
	for (int i=0;i<t.length();i++){
		if (t[i] == '?'){
			cnt++;
			continue;
		}
		a[t[i]-'a']--;
		if (a[t[i]-'a']<0){
			return false;
		}
	}

	int sum = 0;
	for (int i=0;i<26;i++){
		sum += a[i];
	}
	if (sum == cnt){
		return true;
	}
	return false;
}

int main (){
	//freopen ("input.txt","r",stdin);
	//freopen ("output.txt","w",stdout);
	getline(cin,s);
	getline(cin,p);
	if (p.length()>s.length()){
		cout <<0;
		return 0;
	}
	int ans = 0;
	for (int i=0;i<=s.length()-p.length();i++){
		string tt = s.substr(i,p.length());
		if ( analogy(tt)   ){
			ans++;
			//red.insert(tt);
		}
	}
	cout <<ans;
	//cout <<red.size();
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>
#include <cstdlib>
#include <vector>
#include <map>
#include <set>
#include <ctime>
#include <cassert>
#include <queue>
#include <list>
#include <bitset>
using namespace std;
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define forit(v,it) for(typeof(v.begin()) it = v.begin(); it != v.end(); ++it)
typedef long long ll;
typedef pair <int, int> pii;
typedef vector <int> vi;

int cnt[300],a[300];
char s[200000],t[200000];

int main () {
	#ifdef LOCAL
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	scanf("%s\n%s",&s,&t);
	int n = strlen(s), m = strlen(t);
	int res = 0;

	if(n < m) {
		puts("0");
		return 0;
	}
	for(int i=0;i<m;++i) {
		a[t[i] - 'a']++;
		if(islower(s[i])) cnt[s[i] - 'a']++;
	}
	bool ok = true;
	for(int i=0;i<26  &&  ok;++i)
		if(cnt[i] > a[i]) ok = false;
	if(ok) ++res;
	for(int i=1;i<=n-m;++i) {
		if(islower(s[i + m - 1])) cnt[s[i + m - 1] - 'a']++;
		if(islower(s[i - 1])) cnt[s[i - 1] - 'a']--;
		ok = true;
		for(int j=0;j<26  &&  ok;++j)
			if(a[j] < cnt[j]) ok = false;
		if(ok) res++;
	}
	printf("%d",res);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <queue>
#include <stack>

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long int
using namespace std;
int const INF = (1<<29);
int const MAXN = (int)1e5+100;

string s,p;
set <string> red;

bool analogy(string t){
	int a[26];
	for (int i=0;i<26;i++)
		a[i] = 0;
	int cnt = 0;

	for (int i=0;i<p.length();i++){
		a[p[i]-'a']++;
	}
	for (int i=0;i<t.length();i++){
		if (t[i] == '?'){
			cnt++;
			continue;
		}
		a[t[i]-'a']--;
		if (a[t[i]-'a']<0){
			return false;
		}
	}

	int sum = 0;
	for (int i=0;i<26;i++){
		sum += a[i];
	}
	if (sum == cnt){
		return true;
	}
	return false;
}

int main (){
	//freopen ("input.txt","r",stdin);
	//freopen ("output.txt","w",stdout);
	cin >>s;
	cin >>p;
	for (int i=0;i<=s.length()-p.length();i++){
		string tt = s.substr(i,p.length());
		if ( analogy(tt)   ){
			red.insert(tt);
		}
	}
	cout <<red.size();
	return 0;
}


#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
char s[100010],p[100010];
int a[30],b[30];
int main()
{
    gets(s);
    gets(p);
    int slen=strlen(s),plen=strlen(p);
    int sp=0;
    int ans=0,cnt;
    for(int i=0;i<plen;i++)
    {
        a[p[i]-'a']++;
    }
    for(int i=0;i<plen;i++)
    {
        if(s[i]!='?')
            b[p[i]-'a']++;
        else
            sp++;
    }
    for(int j=0;j<26;j++)
    {
        if(a[j]>b[j])cnt++;
    }
    if(sp==cnt)ans++;
    for(int i=0;i+plen<slen;i++)
    {
        cnt=0;
        for(int j=0;j<26;j++)
        {
            if(a[j]>b[j])cnt++;
        }
        if(cnt==sp) ans++;
        if(s[i]=='?')sp--;
        else a[s[i]-'a']--;
        if(s[i+plen]=='?') sp++;
        else a[s[i+plen]-'a']++;
    }
    cout<<ans<<endl;
    return 0;
}


#include<iostream>
#include<string>
using namespace std;
char s[100010],p[100010];
int a[30],b[30];
int main()
{
    gets(s);
    gets(p);
    int slen=strlen(s),plen=strlen(p);
    int sp=0;
    int ans=0,cnt;
    for(int i=0;i<plen;i++)
    {
        a[p[i]-'a']++;
    }
    for(int i=0;i<plen;i++)
    {
        if(s[i]!='?')
            b[p[i]-'a']++;
        else
            sp++;
    }
    for(int j=0;j<26;j++)
    {
        if(a[j]>b[j])cnt++;
    }
    if(sp==cnt)ans++;
    for(int i=0;i+plen<slen;i++)
    {
        cnt=0;
        for(int j=0;j<26;j++)
        {
            if(a[j]>b[j])cnt++;
        }
        if(cnt==sp) ans++;
        if(s[i]=='?')sp--;
        else a[s[i]-'a']--;
        if(s[i+plen]=='?') sp++;
        else a[s[i+plen]-'a']++;
    }
    cout<<ans<<endl;
    return 0;
}


#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
char s[100010],p[100010];
int a[30],b[30];
int main()
{
    gets(s);
    gets(p);
    int slen=strlen(s),plen=strlen(p);
    int sp=0;
    int ans=0,cnt;
    for(int i=0;i<plen;i++)
    {
        a[p[i]-'a']++;
    }
    for(int i=0;i<plen;i++)
    {
        if(s[i]!='?')
            b[s[i]-'a']++;
        else
            sp++;
    }
    for(int i=0;i+plen<=slen;i++)
    {
      //  for(int j=0;j<26;j++)cout<<a[j];
      //  cout<<endl;
      //  for(int j=0;j<26;j++)cout<<b[j];
       // cout<<endl;
        int cnt=0;
        for(int j=0;j<26;j++)
        {
            if(a[j]>b[j])cnt+=a[j]-b[j];
        }
       // cout<<a[0]-b[0]<<endl;
       // cout<<"cnt="<<cnt<<" sp="<<sp<<endl;
        if(cnt==sp) ans++;
        if(s[i]=='?')       sp--;
        else  b[s[i]-'a']--;
        if(s[i+plen]=='?')  sp++;
        else  b[s[i+plen]-'a']++;
    }
    cout<<ans<<endl;
    return 0;
}


#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
char s[200010],p[200010];
int a[30],b[30];
int main()
{
    gets(s);
    gets(p);
    int slen=strlen(s),plen=strlen(p);
    int sp=0;
    int ans=0,cnt;
    for(int i=0;i<plen;i++)
    {
        a[p[i]-'a']++;
    }
    for(int i=0;i<plen;i++)
    {
        if(s[i]!='?')
            b[s[i]-'a']++;
        else
            sp++;
    }
    for(int i=0;;i++)
    {
      //  for(int j=0;j<26;j++)cout<<a[j];
      //  cout<<endl;
      //  for(int j=0;j<26;j++)cout<<b[j];
       // cout<<endl;
        int cnt=0;
        for(int j=0;j<26;j++)
        {
            if(a[j]>b[j])cnt+=a[j]-b[j];
        }
       // cout<<a[0]-b[0]<<endl;
       // cout<<"cnt="<<cnt<<" sp="<<sp<<endl;
        if(cnt==sp) ans++;
        if(i+plen==slen)break;
        if(s[i]=='?')       sp--;
        else  b[s[i]-'a']--;
        if(s[i+plen]=='?')  sp++;
        else  b[s[i+plen]-'a']++;
    }
    cout<<ans<<endl;
    return 0;
}


#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
char s[100010],p[100010];
int a[30],b[30];
int main()
{
    gets(s);
    gets(p);
    int slen=strlen(s),plen=strlen(p);
    int sp=0;
    int ans=0,cnt;
    for(int i=0;i<plen;i++)
    {
        a[p[i]-'a']++;
    }
    for(int i=0;i<plen;i++)
    {
        if(s[i]!='?')
            b[s[i]-'a']++;
        else
            sp++;
    }
    for(int i=0;i+plen<=slen;i++)
    {
      //  for(int j=0;j<26;j++)cout<<a[j];
      //  cout<<endl;
      //  for(int j=0;j<26;j++)cout<<b[j];
       // cout<<endl;
        int cnt=0;
        for(int j=0;j<26;j++)
        {
            if(a[j]>b[j])cnt+=a[j]-b[j];
        }
       // cout<<a[0]-b[0]<<endl;
       // cout<<"cnt="<<cnt<<" sp="<<sp<<endl;
        if(cnt==sp) ans++;
        if(i+plen==slen)break;
        if(s[i]=='?')       sp--;
        else  b[s[i]-'a']--;
        if(s[i+plen]=='?')  sp++;
        else  b[s[i+plen]-'a']++;
    }
    cout<<ans<<endl;
    return 0;
}


#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
char s[200010],p[200010];
int a[30],b[30];
int main()
{
    gets(s);
    gets(p);
    int slen=strlen(s),plen=strlen(p);
    if(slen<plen)
    {
        cout<<0<<endl;
    return 0;
    }
    int sp=0;
    int ans=0,cnt;
    for(int i=0;i<plen;i++)
    {
        a[p[i]-'a']++;
    }
    for(int i=0;i<plen;i++)
    {
        if(s[i]!='?')
            b[s[i]-'a']++;
        else
            sp++;
    }
    for(int i=0;;i++)
    {
      //  for(int j=0;j<26;j++)cout<<a[j];
      //  cout<<endl;
      //  for(int j=0;j<26;j++)cout<<b[j];
       // cout<<endl;
        int cnt=0;
        for(int j=0;j<26;j++)
        {
            if(a[j]>b[j])cnt+=a[j]-b[j];
        }
       // cout<<a[0]-b[0]<<endl;
       // cout<<"cnt="<<cnt<<" sp="<<sp<<endl;
        if(cnt==sp) ans++;
        if(i+plen==slen)break;
        if(s[i]=='?')       sp--;
        else  b[s[i]-'a']--;
        if(s[i+plen]=='?')  sp++;
        else  b[s[i+plen]-'a']++;
    }
    cout<<ans<<endl;
    return 0;
}


#include <iostream>
#include<string>
#include<algorithm>
using namespace std;
int co1[26],co2[26],i,spl,j,ans=0;
string s1,s2;
int chk(int spl){
    for(int i=0;i<26;i++)if(co1[i]!=co2[i]){
        if(co1[i]>co2[i])return 0;
    //  else cout<<i<<" "<<co1[i]<<" "<<co2[i]<<endl;
        if(spl)spl--;
        else return 0;
    }
    return 1;
}
int main() {
    cin>>s1>>s2;
     if(s1.length()<s2.length()){
        cout<<"0"; return 0;
    }
    for(i=0;i<s2.length();i++)co2[(int)(s2[i]-'a')]++;
    for(i=0;i<s2.length();i++)
    if(s1[i]=='?')spl++;
    else co1[(int)(s1[i]-'a')]++;
    if(chk(spl))ans++;
    for(i=s2.length();i<s1.length();i++){
        if(s1[i-s2.length()]=='?')spl--;
        else co1[(int)(s1[i-s2.length()]-'a')]--;
        if(s1[i]=='?')spl++;
        else co1[(int)(s1[i]-'a')]++;
        if(chk(spl)){ans++;}//cout<<i<<" "<<co1[(int)('x'-'a')]<<endl;ans++;}
    }
    cout<<ans;
    return 0;
}


#include <iostream>
#include<string>
#include<algorithm>
using namespace std;
int co1[26],co2[26],i,spl,j,ans=0;
string s1,s2;
int chk(int spl){
    for(int i=0;i<26;i++)if(co1[i]!=co2[i]){
        if(co1[i]>co2[i])return 0;
    //  else cout<<i<<" "<<co1[i]<<" "<<co2[i]<<endl;
        if(spl)spl--;
        else return 0;
    }
    return 1;
}
int main() {
    cin>>s1>>s2;
    for(i=0;i<s2.length();i++)co2[(int)(s2[i]-'a')]++;
    for(i=0;i<s2.length();i++)
    if(s1[i]=='?')spl++;
    else co1[(int)(s1[i]-'a')]++;
    if(chk(spl))ans++;
    for(i=s2.length();i<s1.length();i++){
        if(s1[i-s2.length()]=='?')spl--;
        else co1[(int)(s1[i-s2.length()]-'a')]--;
        if(s1[i]=='?')spl++;
        else co1[(int)(s1[i]-'a')]++;
        if(chk(spl)){ans++;}//cout<<i<<" "<<co1[(int)('x'-'a')]<<endl;ans++;}
    }
    cout<<ans;
    return 0;
}


#include <iostream>
#include<string>
#include<algorithm>
using namespace std;
int co1[26],co2[26],i,spl,j,ans=0;
string s1,s2;
int chk(int spl){
    for(int i=0;i<26;i++)if(co1[i]!=co2[i]){
        if(co1[i]>co2[i])return 0;
    //  else cout<<i<<" "<<co1[i]<<" "<<co2[i]<<endl;
        if(spl)spl--;
        else return 0;
    }
    return 1;
}
int main() {
    cin>>s1>>s2;
    for(i=0;i<s2.length();i++)co2[(int)(s2[i]-'a')]++;
    for(i=0;i<s2.length();i++)
    if(s1[i]=='?')spl++;
    if(s1.length()<s2.length()){
        cout<<"0";
        return 0;
    }
    else co1[(int)(s1[i]-'a')]++;
    if(chk(spl))ans++;
    for(i=s2.length();i<s1.length();i++){
        if(s1[i-s2.length()]=='?')spl--;
        else co1[(int)(s1[i-s2.length()]-'a')]--;
        if(s1[i]=='?')spl++;
        else co1[(int)(s1[i]-'a')]++;
        if(chk(spl)){ans++;}//cout<<i<<" "<<co1[(int)('x'-'a')]<<endl;ans++;}
    }
    cout<<ans;
    return 0;
}


#include <iostream>
#include<string>
#include<algorithm>
using namespace std;
int co1[26],co2[26],i,spl,j,ans=0;
string s1,s2;
int chk(int spl){
    for(int i=0;i<26;i++)if(co1[i]!=co2[i]){
        if(co1[i]>co2[i])return 0;
    //  else cout<<i<<" "<<co1[i]<<" "<<co2[i]<<endl;
        if(spl)spl--;
        else return 0;
    }
    return 1;
}
int main() {
    cin>>s1>>s2;
    for(i=0;i<s2.length();i++)co2[(int)(s2[i]-'a')]++;
    for(i=0;i<s2.length();i++)
        if(s1.length()<s2.length()){
        cout<<"0";
    }
    if(s1[i]=='?')spl++;
    else co1[(int)(s1[i]-'a')]++;
    if(chk(spl))ans++;
    for(i=s2.length();i<s1.length();i++){
        if(s1[i-s2.length()]=='?')spl--;
        else co1[(int)(s1[i-s2.length()]-'a')]--;
        if(s1[i]=='?')spl++;
        else co1[(int)(s1[i]-'a')]++;
        if(chk(spl)){ans++;}//cout<<i<<" "<<co1[(int)('x'-'a')]<<endl;ans++;}
    }
    cout<<ans;
    return 0;
}


#include <iostream>
#include<string>
#include<algorithm>
using namespace std;
int co1[26],co2[26],i,spl,j,ans=0;
string s1,s2;
int chk(int spl){
    for(int i=0;i<26;i++)if(co1[i]!=co2[i]){
        if(co1[i]>co2[i])return 0;
    //  else cout<<i<<" "<<co1[i]<<" "<<co2[i]<<endl;
        if(spl)spl--;
        else return 0;
    }
    return 1;
}
int main() {
    cin>>s1>>s2;
     if(s1.length()<s2.length()){
        cout<<"0";
    }
    for(i=0;i<s2.length();i++)co2[(int)(s2[i]-'a')]++;
    for(i=0;i<s2.length();i++)
    if(s1[i]=='?')spl++;
    else co1[(int)(s1[i]-'a')]++;
    if(chk(spl))ans++;
    for(i=s2.length();i<s1.length();i++){
        if(s1[i-s2.length()]=='?')spl--;
        else co1[(int)(s1[i-s2.length()]-'a')]--;
        if(s1[i]=='?')spl++;
        else co1[(int)(s1[i]-'a')]++;
        if(chk(spl)){ans++;}//cout<<i<<" "<<co1[(int)('x'-'a')]<<endl;ans++;}
    }
    cout<<ans;
    return 0;
}


/*
   Author : SKRCODE
*/

#define DEBUG

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <string.h>
#include <cassert>

using namespace std;

const int oo = 2000000009;
const double eps = 1e-9;
#define mod 1000000007

#define debug printf("ERROR DETECTED...!!\n");
#ifdef DEBUG
    #define debug1(p)                cerr << #p << ": " << p << endl;
    #define debug2(p, q)             cerr << #p << ": " << p << " | " << #q << ": " << q << endl;
    #define debug3(p, q, r)          cerr << #p << ": " << p << " | " << #q << ": " << q << " | " << #r << ": " << r << endl;
    #define debug4(p, q, r, s)       cerr << #p << ": " << p << " | " << #q << ": " << q << " | " << #r << ": " << r << " | " << #s << ": " << s << endl;
    #define debug5(p, q, r, s, t)    cerr << #p << ": " << p << " | " << #q << ": " << q << " | " << #r << ": " << r << " | " << #s << ": " << s << " | " << #t << ": " << t << endl;
    #define debug6(p, q, r, s, t, u) cerr << #p << ": " << p << " | " << #q << ": " << q << " | " << #r << ": " << r << " | " << #s << ": " << s << " | " << #t << ": " << t << " | " << #u << ": " << u << endl;
#else
    #define debug1(p)
    #define debug2(p, q)
    #define debug3(p, q, r)
    #define debug4(p, q, r, s)
    #define debug5(p, q, r, s, t)
    #define debug6(p, q, r, s, t, u)
#endif

typedef vector < int > vi;
typedef pair < int, int> ii;
typedef vector < ii > vii;
typedef set < int > si;
typedef map < string, int > msi;

#define rep(i, a, b) for (int i = int(a); i <= int(b); i++)
#define trvi(c, it) for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define trvii(c, it) for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define trmsi(c, it) for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define pb push_back
#define MEMSET_INF 127
#define MEMSET_HALF_INF 63
#define lsegtree(N) (int)(2 * pow(2.0, floor((log((double)N) / log(2.0)) + 1)))

typedef long long int64;
typedef double float64;

//START

char str1[100005],str2[100005];
int count2[500];

bool isanagram(int beg,int end,int l2)
{
    int countqm=0;
    int count1[500];

    bool flag[500];
    int count=0;
    memset(flag,false,sizeof(flag));
    memset(count1,0,sizeof(count1));
    assert(l2>50000);

    for(int i=beg;i<=end;i++)
    {
        if(str1[i]=='?')
        {
            countqm++;

        }
        else
        {
            count1[str1[i]]++;

        }

    }

    for(int i=0;i<l2;i++)
    {
        if(!flag[str2[i]])
        {//debug1(count2[str2[i]]);
            flag[str2[i]]=true;
            if(count1[str2[i]]==count2[str2[i]]) count+=count1[str2[i]];
            else
            {
                if(count1[str2[i]]>count2[str2[i]]) return false;

                int t = count2[str2[i]] - count1[str2[i]];
                countqm=countqm-t;
                if(countqm<0) return false;
                count+=count2[str2[i]];
            }
        }
    }
    //debug1(count);
    if(count==(end-beg+1)) return true;
    else                 return false;

}

int computedp()
{
    int l1=strlen(str1);
    int l2=strlen(str2);
    int dp;
    memset(count2,0,sizeof(count2));
    for(int i=0;i<l2;i++)
        count2[str2[i]]++;

    dp=0;
    for(int i=1;i<=l1-l2+1;i++)
    {
        int count=0;
        if(isanagram(i-1,i+l2-2,l2))
            count++;

        dp=dp+count;
    }

    return dp;
}

int main()
{

    scanf("%s %s",str1,str2);

    printf("%d\n",computedp());

    return EXIT_SUCCESS;
}


/*
   Author : SKRCODE
*/

#define DEBUG

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <string.h>

using namespace std;

const int oo = 2000000009;
const double eps = 1e-9;
#define mod 1000000007

#define debug printf("ERROR DETECTED...!!\n");
#ifdef DEBUG
    #define debug1(p)                cerr << #p << ": " << p << endl;
    #define debug2(p, q)             cerr << #p << ": " << p << " | " << #q << ": " << q << endl;
    #define debug3(p, q, r)          cerr << #p << ": " << p << " | " << #q << ": " << q << " | " << #r << ": " << r << endl;
    #define debug4(p, q, r, s)       cerr << #p << ": " << p << " | " << #q << ": " << q << " | " << #r << ": " << r << " | " << #s << ": " << s << endl;
    #define debug5(p, q, r, s, t)    cerr << #p << ": " << p << " | " << #q << ": " << q << " | " << #r << ": " << r << " | " << #s << ": " << s << " | " << #t << ": " << t << endl;
    #define debug6(p, q, r, s, t, u) cerr << #p << ": " << p << " | " << #q << ": " << q << " | " << #r << ": " << r << " | " << #s << ": " << s << " | " << #t << ": " << t << " | " << #u << ": " << u << endl;
#else
    #define debug1(p)
    #define debug2(p, q)
    #define debug3(p, q, r)
    #define debug4(p, q, r, s)
    #define debug5(p, q, r, s, t)
    #define debug6(p, q, r, s, t, u)
#endif

typedef vector < int > vi;
typedef pair < int, int> ii;
typedef vector < ii > vii;
typedef set < int > si;
typedef map < string, int > msi;

#define rep(i, a, b) for (int i = int(a); i <= int(b); i++)
#define trvi(c, it) for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define trvii(c, it) for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define trmsi(c, it) for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define pb push_back
#define MEMSET_INF 127
#define MEMSET_HALF_INF 63
#define lsegtree(N) (int)(2 * pow(2.0, floor((log((double)N) / log(2.0)) + 1)))

typedef long long int64;
typedef double float64;

//START

bool isanagram(char str1[],char str2[],int beg,int end,int l2)
{
    bool flag[100005];
    memset(flag,false,sizeof(flag));

    int count=0;
    for(int i=beg;i<=end;i++)
    {
        for(int j=beg;j<=end;j++)
        {

                if(str1[i]!='?')
                {
                    if(str1[i]==str2[j] && !flag[j])
                    {
                        flag[j]=true;
                        count++;
                        break;
                    }
                }
                else
                {
                    count++;
                    break;
                }

        }
    }
     //debug1(count);
     if(count==(end-beg+1)) return true;
     else                 return false;

}

int computedp(char str1[],char str2[])
{
    int l1=strlen(str1);
    int l2=strlen(str2);
    int dp[100005];

    dp[0]=0;
    for(int i=1;i<=l1-l2+1;i++)
    {
        int count=0;
        if(isanagram(str1,str2,i-1,i+l2-2,l2))
            count++;

        dp[i]=dp[i-1]+count;
    }

    return dp[l1-l2+1];
}

int main()
{
    char str1[100005],str2[100005];

    scanf("%s %s",str1,str2);

    printf("%d\n",computedp(str1,str2));

    return EXIT_SUCCESS;
}


/*
   Author : SKRCODE
*/

#define DEBUG

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <string.h>

using namespace std;

const int oo = 2000000009;
const double eps = 1e-9;
#define mod 1000000007

#define debug printf("ERROR DETECTED...!!\n");
#ifdef DEBUG
    #define debug1(p)                cerr << #p << ": " << p << endl;
    #define debug2(p, q)             cerr << #p << ": " << p << " | " << #q << ": " << q << endl;
    #define debug3(p, q, r)          cerr << #p << ": " << p << " | " << #q << ": " << q << " | " << #r << ": " << r << endl;
    #define debug4(p, q, r, s)       cerr << #p << ": " << p << " | " << #q << ": " << q << " | " << #r << ": " << r << " | " << #s << ": " << s << endl;
    #define debug5(p, q, r, s, t)    cerr << #p << ": " << p << " | " << #q << ": " << q << " | " << #r << ": " << r << " | " << #s << ": " << s << " | " << #t << ": " << t << endl;
    #define debug6(p, q, r, s, t, u) cerr << #p << ": " << p << " | " << #q << ": " << q << " | " << #r << ": " << r << " | " << #s << ": " << s << " | " << #t << ": " << t << " | " << #u << ": " << u << endl;
#else
    #define debug1(p)
    #define debug2(p, q)
    #define debug3(p, q, r)
    #define debug4(p, q, r, s)
    #define debug5(p, q, r, s, t)
    #define debug6(p, q, r, s, t, u)
#endif

typedef vector < int > vi;
typedef pair < int, int> ii;
typedef vector < ii > vii;
typedef set < int > si;
typedef map < string, int > msi;

#define rep(i, a, b) for (int i = int(a); i <= int(b); i++)
#define trvi(c, it) for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define trvii(c, it) for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define trmsi(c, it) for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define pb push_back
#define MEMSET_INF 127
#define MEMSET_HALF_INF 63
#define lsegtree(N) (int)(2 * pow(2.0, floor((log((double)N) / log(2.0)) + 1)))

typedef long long int64;
typedef double float64;

//START

char str1[100005],str2[100005];
int count2[500];

bool isanagram(int beg,int end,int l2)
{
    int countqm=0;
    int count1[500];

    bool flag[500];
    int count=0;
    memset(flag,false,sizeof(flag));
    memset(count1,0,sizeof(count1));

    for(int i=beg;i<=end;i++)
    {
        if(str1[i]=='?')
        {
            countqm++;

        }
        else
        {
            count1[str1[i]]++;

        }

    }

    for(int i=0;i<l2;i++)
    {
        if(!flag[str2[i]])
        {//debug1(count2[str2[i]]);
            flag[str2[i]]=true;
            if(count1[str2[i]]==count2[str2[i]]) count+=count1[str2[i]];
            else
            {
                if(count1[str2[i]]>count2[str2[i]]) return false;

                int t = count2[str2[i]] - count1[str2[i]];
                countqm=countqm-t;
                if(countqm<0) return false;
                count+=count2[str2[i]];
            }
        }
    }
    //debug1(count);
    if(count==(end-beg+1)) return true;
    else                 return false;

}

int computedp()
{
    int l1=strlen(str1);
    int l2=strlen(str2);
    int dp;
    memset(count2,0,sizeof(count2));
    for(int i=0;i<l2;i++)
        count2[str2[i]]++;

    dp=0;
    for(int i=1;i<=l1-l2+1;i++)
    {
        int count=0;
        if(isanagram(i-1,i+l2-2,l2))
            count++;

        dp=dp+count;
    }

    return dp;
}

int main()
{

    scanf("%s %s",str1,str2);

    printf("%d\n",computedp());

    return EXIT_SUCCESS;
}


/*
   Author : SKRCODE
*/

#define DEBUG

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <string.h>

using namespace std;

const int oo = 2000000009;
const double eps = 1e-9;
#define mod 1000000007

#define debug printf("ERROR DETECTED...!!\n");
#ifdef DEBUG
    #define debug1(p)                cerr << #p << ": " << p << endl;
    #define debug2(p, q)             cerr << #p << ": " << p << " | " << #q << ": " << q << endl;
    #define debug3(p, q, r)          cerr << #p << ": " << p << " | " << #q << ": " << q << " | " << #r << ": " << r << endl;
    #define debug4(p, q, r, s)       cerr << #p << ": " << p << " | " << #q << ": " << q << " | " << #r << ": " << r << " | " << #s << ": " << s << endl;
    #define debug5(p, q, r, s, t)    cerr << #p << ": " << p << " | " << #q << ": " << q << " | " << #r << ": " << r << " | " << #s << ": " << s << " | " << #t << ": " << t << endl;
    #define debug6(p, q, r, s, t, u) cerr << #p << ": " << p << " | " << #q << ": " << q << " | " << #r << ": " << r << " | " << #s << ": " << s << " | " << #t << ": " << t << " | " << #u << ": " << u << endl;
#else
    #define debug1(p)
    #define debug2(p, q)
    #define debug3(p, q, r)
    #define debug4(p, q, r, s)
    #define debug5(p, q, r, s, t)
    #define debug6(p, q, r, s, t, u)
#endif

typedef vector < int > vi;
typedef pair < int, int> ii;
typedef vector < ii > vii;
typedef set < int > si;
typedef map < string, int > msi;

#define rep(i, a, b) for (int i = int(a); i <= int(b); i++)
#define trvi(c, it) for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define trvii(c, it) for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define trmsi(c, it) for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define pb push_back
#define MEMSET_INF 127
#define MEMSET_HALF_INF 63
#define lsegtree(N) (int)(2 * pow(2.0, floor((log((double)N) / log(2.0)) + 1)))

typedef long long int64;
typedef double float64;

//START
bool flag[100005];
char str1[100005],str2[100005];
bool isanagram(int beg,int end,int l2)
{

    memset(flag,false,sizeof(flag));

    int count=0,countqm=0;
    for(int i=beg;i<=end;i++)
    {

        for(int j=beg;j<=end;j++)
        {

                if(str1[i]!='?')
                {
                    if(str1[i]==str2[j-beg] && !flag[j])
                    {
                        flag[j]=true;
                        count++;
                        break;
                    }
                }
                else
                {
                    countqm++;
                    break;
                }

        }
    }
     //debug1(count+countqm);
     if((count+countqm)==(end-beg+1)) return true;
     else                 return false;

}

int computedp()
{
    int l1=strlen(str1);
    int l2=strlen(str2);
    int dp;

    dp=0;
    for(int i=1;i<=l1-l2+1;i++)
    {
        int count=0;
        if(isanagram(i-1,i+l2-2,l2))
            count++;

        dp=dp+count;
    }

    return dp;
}

int main()
{

    scanf("%s %s",str1,str2);

    printf("%d\n",computedp());

    return EXIT_SUCCESS;
}


/*
   Author : SKRCODE
*/

#define DEBUG

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <string.h>

using namespace std;

const int oo = 2000000009;
const double eps = 1e-9;
#define mod 1000000007

#define debug printf("ERROR DETECTED...!!\n");
#ifdef DEBUG
    #define debug1(p)                cerr << #p << ": " << p << endl;
    #define debug2(p, q)             cerr << #p << ": " << p << " | " << #q << ": " << q << endl;
    #define debug3(p, q, r)          cerr << #p << ": " << p << " | " << #q << ": " << q << " | " << #r << ": " << r << endl;
    #define debug4(p, q, r, s)       cerr << #p << ": " << p << " | " << #q << ": " << q << " | " << #r << ": " << r << " | " << #s << ": " << s << endl;
    #define debug5(p, q, r, s, t)    cerr << #p << ": " << p << " | " << #q << ": " << q << " | " << #r << ": " << r << " | " << #s << ": " << s << " | " << #t << ": " << t << endl;
    #define debug6(p, q, r, s, t, u) cerr << #p << ": " << p << " | " << #q << ": " << q << " | " << #r << ": " << r << " | " << #s << ": " << s << " | " << #t << ": " << t << " | " << #u << ": " << u << endl;
#else
    #define debug1(p)
    #define debug2(p, q)
    #define debug3(p, q, r)
    #define debug4(p, q, r, s)
    #define debug5(p, q, r, s, t)
    #define debug6(p, q, r, s, t, u)
#endif

typedef vector < int > vi;
typedef pair < int, int> ii;
typedef vector < ii > vii;
typedef set < int > si;
typedef map < string, int > msi;

#define rep(i, a, b) for (int i = int(a); i <= int(b); i++)
#define trvi(c, it) for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define trvii(c, it) for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define trmsi(c, it) for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define pb push_back
#define MEMSET_INF 127
#define MEMSET_HALF_INF 63
#define lsegtree(N) (int)(2 * pow(2.0, floor((log((double)N) / log(2.0)) + 1)))

typedef long long int64;
typedef double float64;

//START

bool isanagram(char str1[],char str2[],int beg,int end,int l2)
{
    bool flag[100005];
    memset(flag,false,sizeof(flag));

    int count=0,countqm=0;
    for(int i=beg;i<=end;i++)
    {

        for(int j=beg;j<=end;j++)
        {

                if(str1[i]!='?')
                {
                    if(str1[i]==str2[j-beg] && !flag[j])
                    {
                        flag[j]=true;
                        count++;
                        break;
                    }
                }
                else
                {
                    countqm++;
                    break;
                }

        }
    }
     //debug1(count+countqm);
     if((count+countqm)==(end-beg+1)) return true;
     else                 return false;

}

int computedp(char str1[],char str2[])
{
    int l1=strlen(str1);
    int l2=strlen(str2);
    int dp[100005];

    dp[0]=0;
    for(int i=1;i<=l1-l2+1;i++)
    {
        int count=0;
        if(isanagram(str1,str2,i-1,i+l2-2,l2))
            count++;

        dp[i]=dp[i-1]+count;
    }

    return dp[l1-l2+1];
}

int main()
{
    char str1[100005],str2[100005];

    scanf("%s %s",str1,str2);

    printf("%d\n",computedp(str1,str2));

    return EXIT_SUCCESS;
}


/*
   Author : SKRCODE
*/

#define DEBUG

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <string.h>
#include <cassert>

using namespace std;

const int oo = 2000000009;
const double eps = 1e-9;
#define mod 1000000007

#define debug printf("ERROR DETECTED...!!\n");
#ifdef DEBUG
    #define debug1(p)                cerr << #p << ": " << p << endl;
    #define debug2(p, q)             cerr << #p << ": " << p << " | " << #q << ": " << q << endl;
    #define debug3(p, q, r)          cerr << #p << ": " << p << " | " << #q << ": " << q << " | " << #r << ": " << r << endl;
    #define debug4(p, q, r, s)       cerr << #p << ": " << p << " | " << #q << ": " << q << " | " << #r << ": " << r << " | " << #s << ": " << s << endl;
    #define debug5(p, q, r, s, t)    cerr << #p << ": " << p << " | " << #q << ": " << q << " | " << #r << ": " << r << " | " << #s << ": " << s << " | " << #t << ": " << t << endl;
    #define debug6(p, q, r, s, t, u) cerr << #p << ": " << p << " | " << #q << ": " << q << " | " << #r << ": " << r << " | " << #s << ": " << s << " | " << #t << ": " << t << " | " << #u << ": " << u << endl;
#else
    #define debug1(p)
    #define debug2(p, q)
    #define debug3(p, q, r)
    #define debug4(p, q, r, s)
    #define debug5(p, q, r, s, t)
    #define debug6(p, q, r, s, t, u)
#endif

typedef vector < int > vi;
typedef pair < int, int> ii;
typedef vector < ii > vii;
typedef set < int > si;
typedef map < string, int > msi;

#define rep(i, a, b) for (int i = int(a); i <= int(b); i++)
#define trvi(c, it) for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define trvii(c, it) for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define trmsi(c, it) for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define pb push_back
#define MEMSET_INF 127
#define MEMSET_HALF_INF 63
#define lsegtree(N) (int)(2 * pow(2.0, floor((log((double)N) / log(2.0)) + 1)))

typedef long long int64;
typedef double float64;

//START

char str1[100005],str2[100005];
int count2[500];

bool isanagram(int beg,int end,int l2)
{
    int countqm=0;
    int count1[500];

    bool flag[500];
    int count=0;
    memset(flag,false,sizeof(flag));
    memset(count1,0,sizeof(count1));
    assert(l2<50000);

    for(int i=beg;i<=end;i++)
    {
        if(str1[i]=='?')
        {
            countqm++;

        }
        else
        {
            count1[str1[i]]++;

        }

    }

    for(int i=0;i<l2;i++)
    {
        if(!flag[str2[i]])
        {//debug1(count2[str2[i]]);
            flag[str2[i]]=true;
            if(count1[str2[i]]==count2[str2[i]]) count+=count1[str2[i]];
            else
            {
                if(count1[str2[i]]>count2[str2[i]]) return false;

                int t = count2[str2[i]] - count1[str2[i]];
                countqm=countqm-t;
                if(countqm<0) return false;
                count+=count2[str2[i]];
            }
        }
    }
    //debug1(count);
    if(count==(end-beg+1)) return true;
    else                 return false;

}

int computedp()
{
    int l1=strlen(str1);
    int l2=strlen(str2);
    int dp;
    memset(count2,0,sizeof(count2));
    for(int i=0;i<l2;i++)
        count2[str2[i]]++;

    dp=0;
    for(int i=1;i<=l1-l2+1;i++)
    {
        int count=0;
        if(isanagram(i-1,i+l2-2,l2))
            count++;

        dp=dp+count;
    }

    return dp;
}

int main()
{

    scanf("%s %s",str1,str2);

    printf("%d\n",computedp());

    return EXIT_SUCCESS;
}


/*
   Author : SKRCODE
*/

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <string.h>
#include <cassert>
#include <climits>

using namespace std;

const int oo = int(2e9) + 9;
const double eps = 1e-9;
const double pi = 3.14159265358979323846264338327950;

#define debug printf("ERROR DETECTED...!!\n");
#define debug1(p)        cerr << #p << ": " << p << endl;
#define debug2(p, q)     cerr << #p << ": " << p << " | " << #q << ": " << q << endl;
#define debug3(p, q, r)  cerr << #p << ": " << p << " | " << #q << ": " << q << " | " << #r << ": " << r << endl;

#define  takeinput() freopen("ip.txt","r",stdin);
#define  takeoutput() freopen("op.txt","w",stdout);

typedef vector < int > vi;
typedef pair < int, int> ii;
typedef vector < ii > vii;

#define trvi(c, it) for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define trvii(c, it) for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define pb push_back
#define mp make_pair
#define lsegtree(N) (int)(2 * pow(2.0, floor((log((double)N) / log(2.0)) + 1)))

typedef long long int64;
typedef double float64;

//START

const int nmax = 100005;
int dp[nmax][30];

int main() { //takeinput();
    char a[nmax];
    char b[nmax];
    int cnt[30];
    scanf("%s %s",a,b);

    int n1 = strlen(a);
    int n2 = strlen(b);
    for(int i=1;i<=n1;i++)
        for(int j=1;j<=26;j++)
            dp[i][j] = dp[i-1][j] + (a[i-1]==j+'a'-1);
    int cntqm[nmax];
    cntqm[0]=0;
    for(int i=1;i<=n1;i++)cntqm[i] = cntqm[i-1]+(a[i-1]=='?');
    memset(cnt,0,sizeof(cnt));
    for(int i=0;i<n2;i++)
        cnt[b[i]-'a'+1]++;
    int ans = 0;
    for(int i=1;i<=n1-n2+1;i++) {
        bool f = true;
        int sum = 0;
        for(int j=1;j<=26;j++) {
            int sum1 = 0,sum2 = 0;
            sum1+=(-dp[i-1][j] + dp[i+n2-1][j]);
            sum2+=cnt[j];//debug3(j+'a'-1,sum1,sum2);
            if(sum1>sum2)f = false;
            else
            sum+=(sum2-sum1);
        }
        //debug1(sum);
        if(sum!=cntqm[i+n2-1]-cntqm[i-1])f = false;
        if(f)ans++;
    }
    cout<<ans<<endl;
    return 0;
}


/*
   Author : SKRCODE
*/

#define DEBUG

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <string.h>

using namespace std;

const int oo = 2000000009;
const double eps = 1e-9;
#define mod 1000000007

#define debug printf("ERROR DETECTED...!!\n");
#ifdef DEBUG
    #define debug1(p)                cerr << #p << ": " << p << endl;
    #define debug2(p, q)             cerr << #p << ": " << p << " | " << #q << ": " << q << endl;
    #define debug3(p, q, r)          cerr << #p << ": " << p << " | " << #q << ": " << q << " | " << #r << ": " << r << endl;
    #define debug4(p, q, r, s)       cerr << #p << ": " << p << " | " << #q << ": " << q << " | " << #r << ": " << r << " | " << #s << ": " << s << endl;
    #define debug5(p, q, r, s, t)    cerr << #p << ": " << p << " | " << #q << ": " << q << " | " << #r << ": " << r << " | " << #s << ": " << s << " | " << #t << ": " << t << endl;
    #define debug6(p, q, r, s, t, u) cerr << #p << ": " << p << " | " << #q << ": " << q << " | " << #r << ": " << r << " | " << #s << ": " << s << " | " << #t << ": " << t << " | " << #u << ": " << u << endl;
#else
    #define debug1(p)
    #define debug2(p, q)
    #define debug3(p, q, r)
    #define debug4(p, q, r, s)
    #define debug5(p, q, r, s, t)
    #define debug6(p, q, r, s, t, u)
#endif

typedef vector < int > vi;
typedef pair < int, int> ii;
typedef vector < ii > vii;
typedef set < int > si;
typedef map < string, int > msi;

#define rep(i, a, b) for (int i = int(a); i <= int(b); i++)
#define trvi(c, it) for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define trvii(c, it) for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define trmsi(c, it) for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define pb push_back
#define MEMSET_INF 127
#define MEMSET_HALF_INF 63
#define lsegtree(N) (int)(2 * pow(2.0, floor((log((double)N) / log(2.0)) + 1)))

typedef long long int64;
typedef double float64;

//START

char str1[100005],str2[100005];

bool isanagram(int beg,int end,int l2)
{
    int countqm=0;
    int count1[500];
    int count2[500];
    bool flag[500];
    int count=0;
    memset(flag,false,sizeof(flag));
    memset(count1,0,sizeof(count1));
    memset(count2,0,sizeof(count2));

    for(int i=beg;i<=end;i++)
    {
        if(str1[i]=='?')
        {
            countqm++;

        }
        else
        {
            count1[str1[i]]++;

        }
        count2[str2[i-beg]]++;
    }

    for(int i=0;i<l2;i++)
    {
        if(!flag[str2[i]])
        {//debug1(count2[str2[i]]);
            flag[str2[i]]=true;
            if(count1[str2[i]]==count2[str2[i]]) count+=count1[str2[i]];
            else
            {
                if(count1[str2[i]]>count2[str2[i]]) return false;

                int t = count2[str2[i]] - count1[str2[i]];
                countqm=countqm-t;
                if(countqm<0) return false;
                count+=count2[str2[i]];
            }
        }
    }
    //debug1(count);
    if(count==(end-beg+1)) return true;
    else                 return false;

}

int computedp()
{
    int l1=strlen(str1);
    int l2=strlen(str2);
    int dp;

    dp=0;
    for(int i=1;i<=l1-l2+1;i++)
    {
        int count=0;
        if(isanagram(i-1,i+l2-2,l2))
            count++;

        dp=dp+count;
    }

    return dp;
}

int main()
{

    scanf("%s %s",str1,str2);

    printf("%d\n",computedp());

    return EXIT_SUCCESS;
}


#include<iostream>
#include<cstdio>
#include<sstream>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<deque>
#include<queue>
#include<stack>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<bitset>
#include<cctype>
#include<ctime>
using namespace std;

typedef long long ll;
#define INF 2023456789
#define EPS 1e-11
#define PI acos(-1)
#define FOR(i,a,b) for(int i = a; i < b; ++i)
#define REP(i,a,b) for(int i = a; i <= b; ++i)
#define FORD(i,a,b) for(int i = a; i >= b; --i)
#define FORV(i,vt) for(size_t i = 0; i < vt.size(); ++i)
#define siz(x) (int)x.size()
#define pb push_back
#define m_p make_pair
#define pii pair<int,int>
#define pss pair<string, string>
#define psi pair<string, int>
#define mpsr make_pair(sender, receiver)
#define mprs make_pair(receiver, sender)

struct TeamInfo {
    string name;
    int points;
    int wins;
    int games;
    int ties;
    int losses;
    int goaldif;
    int goalscored;
    int goalagainst;
    int rank;
    TeamInfo() {
        points = 0;
        wins = 0;
        games = 0;
        ties = 0;
        losses = 0;
        goaldif = 0;
        goalscored = 0;
        goalagainst = 0;
        rank = 0;
    }
    void display() {
        cout << rank << ") " << name << " " << points << "p, " << games
                << "g (" << wins << "-" << ties << "-" << losses << "), "
                << goaldif << "gd (" << goalscored << "-" << goalagainst
                << ")\n";
    }
};

struct TimeFormat {
    int hour;
    int minute;
    TimeFormat() {
    }
    void display() {
        cout << hour << ":";
        if (minute < 10) {
            cout << "0" << minute;
        } else
            cout << minute;
    }
};

struct Appointment {
    TimeFormat start;
    TimeFormat end;
    string name;
    Appointment() {
    }

};

TimeFormat dist(TimeFormat a, TimeFormat b) {
    int minutea = a.hour * 60 + a.minute;
    int minuteb = b.hour * 60 + b.minute;
    int d = minuteb - minutea;
    TimeFormat ret;
    ret.hour = d / 60;
    ret.minute = d % 60;
    return ret;
}

bool cmpTimeFormat(TimeFormat a, TimeFormat b) {
    if (a.hour != b.hour) {
        return a.hour < b.hour;
    }
    return a.minute < b.minute;
}

bool cmpAppointment(Appointment a, Appointment b) {
    return cmpTimeFormat(a.start, b.start);
}

int myabs(int x) {
    return x < 0 ? -x : x;
}
int gcd(int x, int y) {
    return y == 0 ? x : gcd(y, x % y);
}

int toInt(char xx) {
    return xx - '0';
}

char toChar(int xx) {
    return xx + '0';
}

bool isNum(char xx) {
    return ('0' <= xx && xx <= '9');
}

bool isCharacter(char xx) {
    return (('a' <= xx && xx <= 'z') || ('A' <= xx && xx <= 'Z'));
}

bool isUpper(char xx) {
    return ('A' <= xx && xx <= 'Z');
}

bool isLower(char xx) {
    return ('a' <= xx && xx <= 'z');
}

bool isPalin(string x) {
    int len = x.length();
    REP(i,0,len/2) {
        if (x[i] != x[len - 1 - i])
            return false;
    }
    return true;
}

void swapInt(int &x, int &y) {
    x = x ^ y;
    y = x ^ y;
    x = x ^ y;
}

string tolowerStr(string x) {
    string ret = "";
    FOR(i,0,siz(x)) {
        ret.pb(tolower(x[i]));
    }
    return ret;
}

string toupperStr(string x) {
    string ret = "";
    FOR(i,0,siz(x)) {
        ret.pb(toupper(x[i]));
    }
    return ret;
}
template<class T>
bool isInArray(T x, vector<T> vt) {
    FOR(i,0,siz(vt)) {
        if (vt[i] == x) {
            return true;
        }
    }
    return false;
}
string trim(string x) {
    int l = 0, r = x.size() - 1;
    char arr[] = { '\f', '\v', '\t', '\r', '\n', ' ' };
    vector<char> delimiter(arr, arr + sizeof(arr) / sizeof(char));
    while (isInArray(x[l], delimiter)) {
        l++;
    }
    while (isInArray(x[r], delimiter)) {
        r--;
    }
    return x.substr(l, r - l + 1);
}

vector<string> getToken(string x, vector<char> tokens) {
    int icounter = 0, lastIndex = x.length() - 1;
    vector<string> ret;
    for (;;) {
        string tmp = "";
        while (icounter <= lastIndex && isInArray(x[icounter], tokens))
            icounter++;
        while (icounter <= lastIndex && !isInArray(x[icounter], tokens)) {
            tmp.pb(x[icounter]);
            icounter++;
        }
        if (tmp.length() > 0)
            ret.pb(tmp);
        if (icounter > lastIndex)
            break;
    }
    return ret;
}

inline void clear_buffer() {
    string tmp;
    getline(cin, tmp);
}

bool cmp(string sx, string sy) {
    string s1 = sx + sy;
    string s2 = sy + sx;
    return s1 > s2;
}

ll val(ll x) {
    if (x < 0)
        return -x;
    return x;
}
const int bfsz = 1 << 16;
char bf[bfsz + 5];
int rsz = 0;
int ptr = 0;

char gc() {
    if (rsz <= 0) {
        ptr = 0;
        rsz = fread(bf, 1, bfsz, stdin);
        if (rsz <= 0)
            return EOF;
    }
    --rsz;
    return bf[ptr++];
}

void ga(char &c) {
    c = EOF;
    while (!isalpha(c))
        c = gc();
}

int gs(char s[]) {
    int l = 0;
    char c = gc();
    while (isspace(c))
        c = gc();
    while (c != EOF && !isspace(c)) {
        s[l++] = c;
        c = gc();
    }
    s[l] = '\0';
    return l;
}

template<class T> bool gi(T &v) {

    v = 0;
    char c = gc();
    while (c != EOF && c != '-' && !isdigit(c))
        c = gc();
    if (c == EOF)
        return false;
    bool neg = c == '-';
    if (neg)
        c = gc();

    while (isdigit(c)) {
        v = v * 10 + c - '0';
        c = gc();
    }
    if (neg)
        v = -v;
    return true;

}

template<class T> inline void checkmin(T &a, T b) {
    if (b < a)
        a = b;
}

/* example of very quick - read :
 * read int : gi(n) <=> scanf("%d",&n);
 * read char : ga(x) <=> scanf("%c",&x);
 */

/*** IMPLEMENTATION ***/

string s, p;
int lens, lenp;
map<char, int> hashTable, pattern;
const char ques = '?';

void readEachTest() {

}

void initEachTest() {

}

void solveEachTest() {

}

void read() {
    cin >> s;
    cin >> p;
    lens = s.length();
    lenp = p.length();
}

void init() {
    for (char x = 'a'; x <= 'z'; ++x) {
        hashTable[x] = 0;
        pattern[x] = 0;
    }
    FOR(i,0,lenp) {
        hashTable[p[i]]++;
    }
}

int isAnagram(int index) {

    for (char x = 'a'; x <= 'z'; ++x) {
        if (hashTable[x] < pattern[x]) {
            //cout << index << " ; char " << x << " make it wrong\n";
            return 0;
        }
    }
    return 1;
}

void solve() {
    int ret = 0;
    int lastIndex = 0;
    if (lens > lenp) {
        int index = 0;
        while (index < lens) {
            if (s[index] != ques) {
                pattern[s[index]]++;
            }
            if (index > lenp - 1) {
                // build pattern and compare
                if (s[lastIndex] != ques) {
                    pattern[s[lastIndex]]--;
                }
                lastIndex++;
                ret += isAnagram(index);
            } else if (index == lenp - 1) {
                // compare
                ret += isAnagram(index);
            }
            //cout << index << " " << ret << endl;
            index++;
        }
    }
    cout << ret;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
#endif
    read();
    init();
    solve();
    return 0;
}


#include<iostream>
#include<cstdio>
#include<sstream>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<deque>
#include<queue>
#include<stack>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<bitset>
#include<cctype>
#include<ctime>
using namespace std;

typedef long long ll;
#define INF 2023456789
#define EPS 1e-11
#define PI acos(-1)
#define FOR(i,a,b) for(int i = a; i < b; ++i)
#define REP(i,a,b) for(int i = a; i <= b; ++i)
#define FORD(i,a,b) for(int i = a; i >= b; --i)
#define FORV(i,vt) for(size_t i = 0; i < vt.size(); ++i)
#define siz(x) (int)x.size()
#define pb push_back
#define m_p make_pair
#define pii pair<int,int>
#define pss pair<string, string>
#define psi pair<string, int>
#define mpsr make_pair(sender, receiver)
#define mprs make_pair(receiver, sender)

struct TeamInfo {
    string name;
    int points;
    int wins;
    int games;
    int ties;
    int losses;
    int goaldif;
    int goalscored;
    int goalagainst;
    int rank;
    TeamInfo() {
        points = 0;
        wins = 0;
        games = 0;
        ties = 0;
        losses = 0;
        goaldif = 0;
        goalscored = 0;
        goalagainst = 0;
        rank = 0;
    }
    void display() {
        cout << rank << ") " << name << " " << points << "p, " << games
                << "g (" << wins << "-" << ties << "-" << losses << "), "
                << goaldif << "gd (" << goalscored << "-" << goalagainst
                << ")\n";
    }
};

struct TimeFormat {
    int hour;
    int minute;
    TimeFormat() {
    }
    void display() {
        cout << hour << ":";
        if (minute < 10) {
            cout << "0" << minute;
        } else
            cout << minute;
    }
};

struct Appointment {
    TimeFormat start;
    TimeFormat end;
    string name;
    Appointment() {
    }

};

TimeFormat dist(TimeFormat a, TimeFormat b) {
    int minutea = a.hour * 60 + a.minute;
    int minuteb = b.hour * 60 + b.minute;
    int d = minuteb - minutea;
    TimeFormat ret;
    ret.hour = d / 60;
    ret.minute = d % 60;
    return ret;
}

bool cmpTimeFormat(TimeFormat a, TimeFormat b) {
    if (a.hour != b.hour) {
        return a.hour < b.hour;
    }
    return a.minute < b.minute;
}

bool cmpAppointment(Appointment a, Appointment b) {
    return cmpTimeFormat(a.start, b.start);
}

int myabs(int x) {
    return x < 0 ? -x : x;
}
int gcd(int x, int y) {
    return y == 0 ? x : gcd(y, x % y);
}

int toInt(char xx) {
    return xx - '0';
}

char toChar(int xx) {
    return xx + '0';
}

bool isNum(char xx) {
    return ('0' <= xx && xx <= '9');
}

bool isCharacter(char xx) {
    return (('a' <= xx && xx <= 'z') || ('A' <= xx && xx <= 'Z'));
}

bool isUpper(char xx) {
    return ('A' <= xx && xx <= 'Z');
}

bool isLower(char xx) {
    return ('a' <= xx && xx <= 'z');
}

bool isPalin(string x) {
    int len = x.length();
    REP(i,0,len/2) {
        if (x[i] != x[len - 1 - i])
            return false;
    }
    return true;
}

void swapInt(int &x, int &y) {
    x = x ^ y;
    y = x ^ y;
    x = x ^ y;
}

string tolowerStr(string x) {
    string ret = "";
    FOR(i,0,siz(x)) {
        ret.pb(tolower(x[i]));
    }
    return ret;
}

string toupperStr(string x) {
    string ret = "";
    FOR(i,0,siz(x)) {
        ret.pb(toupper(x[i]));
    }
    return ret;
}
template<class T>
bool isInArray(T x, vector<T> vt) {
    FOR(i,0,siz(vt)) {
        if (vt[i] == x) {
            return true;
        }
    }
    return false;
}
string trim(string x) {
    int l = 0, r = x.size() - 1;
    char arr[] = { '\f', '\v', '\t', '\r', '\n', ' ' };
    vector<char> delimiter(arr, arr + sizeof(arr) / sizeof(char));
    while (isInArray(x[l], delimiter)) {
        l++;
    }
    while (isInArray(x[r], delimiter)) {
        r--;
    }
    return x.substr(l, r - l + 1);
}

vector<string> getToken(string x, vector<char> tokens) {
    int icounter = 0, lastIndex = x.length() - 1;
    vector<string> ret;
    for (;;) {
        string tmp = "";
        while (icounter <= lastIndex && isInArray(x[icounter], tokens))
            icounter++;
        while (icounter <= lastIndex && !isInArray(x[icounter], tokens)) {
            tmp.pb(x[icounter]);
            icounter++;
        }
        if (tmp.length() > 0)
            ret.pb(tmp);
        if (icounter > lastIndex)
            break;
    }
    return ret;
}

inline void clear_buffer() {
    string tmp;
    getline(cin, tmp);
}

bool cmp(string sx, string sy) {
    string s1 = sx + sy;
    string s2 = sy + sx;
    return s1 > s2;
}

ll val(ll x) {
    if (x < 0)
        return -x;
    return x;
}
const int bfsz = 1 << 16;
char bf[bfsz + 5];
int rsz = 0;
int ptr = 0;

char gc() {
    if (rsz <= 0) {
        ptr = 0;
        rsz = fread(bf, 1, bfsz, stdin);
        if (rsz <= 0)
            return EOF;
    }
    --rsz;
    return bf[ptr++];
}

void ga(char &c) {
    c = EOF;
    while (!isalpha(c))
        c = gc();
}

int gs(char s[]) {
    int l = 0;
    char c = gc();
    while (isspace(c))
        c = gc();
    while (c != EOF && !isspace(c)) {
        s[l++] = c;
        c = gc();
    }
    s[l] = '\0';
    return l;
}

template<class T> bool gi(T &v) {

    v = 0;
    char c = gc();
    while (c != EOF && c != '-' && !isdigit(c))
        c = gc();
    if (c == EOF)
        return false;
    bool neg = c == '-';
    if (neg)
        c = gc();

    while (isdigit(c)) {
        v = v * 10 + c - '0';
        c = gc();
    }
    if (neg)
        v = -v;
    return true;

}

template<class T> inline void checkmin(T &a, T b) {
    if (b < a)
        a = b;
}

/* example of very quick - read :
 * read int : gi(n) <=> scanf("%d",&n);
 * read char : ga(x) <=> scanf("%c",&x);
 */

/*** IMPLEMENTATION ***/

string s, p;
int lens, lenp;
map<char, int> hashTable, pattern;
const char ques = '?';

void readEachTest() {

}

void initEachTest() {

}

void solveEachTest() {

}

void read() {
    cin >> s;
    cin >> p;
    lens = s.length();
    lenp = p.length();
}

void init() {
    for (char x = 'a'; x <= 'z'; ++x) {
        hashTable[x] = 0;
        pattern[x] = 0;
    }
    FOR(i,0,lenp) {
        hashTable[p[i]]++;
    }
}

int isAnagram(int index) {

    for (char x = 'a'; x <= 'z'; ++x) {
        if (hashTable[x] < pattern[x]) {
            //cout << index << " ; char " << x << " make it wrong\n";
            return 0;
        }
    }
    return 1;
}

void solve() {
    int ret = 0;
    int lastIndex = 0;
    if (lens >= lenp) {
        int index = 0;
        while (index < lens) {
            if (s[index] != ques) {
                pattern[s[index]]++;
            }
            if (index > lenp - 1) {
                // build pattern and compare
                if (s[lastIndex] != ques) {
                    pattern[s[lastIndex]]--;
                }
                lastIndex++;
                ret += isAnagram(index);
            } else if (index == lenp - 1) {
                // compare
                ret += isAnagram(index);
            }
            //cout << index << " " << ret << endl;
            index++;
        }
    }
    cout << ret;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
#endif
    read();
    init();
    solve();
    return 0;
}


#include<iostream>
#include<cstdio>
#include<sstream>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<deque>
#include<queue>
#include<stack>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<bitset>
#include<cctype>
using namespace std;

typedef long long ll;
#define INF 2023456789
#define EPS 1e-11
#define PI acos(-1)
#define FOR(i,a,b) for(int i = a; i < b; ++i)
#define REP(i,a,b) for(int i = a; i <= b; ++i)
#define FORD(i,a,b) for(int i = a; i >= b; --i)
#define FORV(i,vt) for(size_t i = 0; i < vt.size(); ++i)

int gcd(int x, int y) {
    return y == 0 ? x : gcd(y, x % y);
}

int toInt(char xx) {
    return xx - '0';
}

char toChar(int xx) {
    return xx + '0';
}

bool isNum(char xx) {
    return ('0' <= xx && xx <= '9');
}

string s, p;
int res = 0;

void read() {
    cin >> s >> p;
}

bool anagram(string x, string y){ // x : consider, y : base
    map<char, int> mp1, mp2;
    int nz = 0;
    int len = x.length();
    FOR(i,0,len){
        if(x[i] != '?')
            mp1[x[i]]++;
        else {
            nz++;
        }
        mp2[y[i]]++;
    }
    int differ = 0;
    FOR(i,0,len){
        if(mp1[x[i]] > mp2[x[i]]){
            return false;
        }
        differ += mp2[x[i]] - mp1[x[i]];
    }
    if(differ == 0 || differ == nz){
        return true;
    }
    return false;
}

void init() {

}

void solve() {
    string tmp = "";
    int lens = s.length();
    int lenp = p.length();
    REP(i,0,lens-lenp){
        tmp = "";
        tmp += s[i];
        tmp += s[i+1];
        tmp += s[i+2];
        if(anagram(tmp, p)){
            //cout << "tmp = " << tmp << " p = " << p << endl;
            res++;
        }
    }
    cout << res;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
#endif
    read();
    init();
    solve();
}


#include<iostream>
#include<cstdio>
#include<sstream>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<deque>
#include<queue>
#include<stack>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<bitset>
#include<cctype>
using namespace std;

typedef long long ll;
#define INF 2023456789
#define EPS 1e-11
#define PI acos(-1)
#define FOR(i,a,b) for(int i = a; i < b; ++i)
#define REP(i,a,b) for(int i = a; i <= b; ++i)
#define FORD(i,a,b) for(int i = a; i >= b; --i)
#define FORV(i,vt) for(size_t i = 0; i < vt.size(); ++i)

int gcd(int x, int y) {
    return y == 0 ? x : gcd(y, x % y);
}

int toInt(char xx) {
    return xx - '0';
}

char toChar(int xx) {
    return xx + '0';
}

bool isNum(char xx) {
    return ('0' <= xx && xx <= '9');
}

string s, p;
int res = 0;

void read() {
    cin >> s >> p;
}

bool anagram(string x, string y){ // x : consider, y : base
    //cout << "x = " << x << endl;
    if(x == y) return true;
    map<char, int> mp1, mp2;
    int nz = 0;
    int len = x.length();
    FOR(i,0,len){
        if(x[i] != '?')
            mp1[x[i]]++;
        else {
            nz++;
        }
        mp2[y[i]]++;
    }
    if(mp1 == mp2) {
        return true;
    }
    int differ = 0;
    map<char, int>::iterator it;
    for(it = mp1.begin(); it != mp1.end(); ++it){
        char xx = (*it).first;
        if(mp1[xx] > mp2[xx]){
            return false;
        }
    }
    for(it = mp2.begin(); it != mp2.end(); ++it){
        char xx = (*it).first;
        differ += mp2[xx] - mp1[xx];
    }
//  cout << x << endl;
//  cout << "nz = " << nz << endl;
//  cout << "differ = " << differ << endl;
    if(differ == nz){
        return true;
    }
    return false;
}

void init() {

}

void solve() {
    string tmp = "";
    int lens = s.length();
    int lenp = p.length();
    if(lenp > lens){
        cout << "0";
        return;
    }
    REP(i,0,lens-lenp){
        tmp = s.substr(i,lenp);
        if(anagram(tmp, p)){
            //cout << "tmp = " << tmp << " p = " << p << endl;
            res++;
        }
    }
    cout << res;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
#endif
    read();
    init();
    solve();
}