#pragma comment (linker,   "/STACK:100000000")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define FILL(A,value) memset(A,value,sizeof(A))
#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair

typedef long long Int;
typedef vector <int> VI;
typedef pair <int, int> PII;

const int INF = 1000000000;
const int MAX = 1<<19;
const int MAX2 = 1<<18;

#define MOD 1000000009
#define K 300

int n, m, h;
int A[MAX];
int B[MAX];
int AA[MAX];
int BB[MAX];
int I[MAX];
int C[MAX];

int D[MAX];
int W[MAX];
int M[MAX];

int Cnt[MAX];

void upd(int x)
{
    int m = INF;
    FOR (i,x*K,x*K+K)
    {
        W[i] += D[x];
        m = min(m, W[i]);
    }
    M[x] = m;
    D[x] = 0;
}

void add(int l, int r, int d)
{
    int ll = l;
    while (l <= r)
        if ((l % K == 0) && (l+K-1 <= r))
        {
            D[l / K] += d;
            l += K;
        }
        else
        {
            W[l] += d;
            if (((l+1) % K == 0) || l == r)
                upd(l / K);
            l ++;
        }
}

void add(int x)
{
    W[x] = (Cnt[x] == 0 ? W[x] - INF + C[x] : W[x]);
    upd(x / K);
    add(x, n-1, -1);
    ++ Cnt[x];
}

void del(int x)
{
    add(x, n-1, 1);
    -- Cnt[x];
    W[x] = (Cnt[x] == 0 ? W[x] - C[x] + INF : W[x]);
    upd(x / K);
}

int get()
{
    int res = INF;
    for (int i = 0; i < n; i += K)
    {
        if (i+K-1 < n)
            res = min(res, M[i/K] + D[i/K]);
        else
        {
            FOR (j,i,n)
                res = min(res, W[j] + D[j/K]);
        }
    }
    return res;
}

int main()
{
    scanf("%d %d %d", &n, &m, &h);
    FOR (i,0,m)
    {
        scanf("%d", &B[i]);
        BB[i] = B[i];
    }
    FOR (i,0,n)
    {
        scanf("%d", &A[i]);
        AA[i] = A[i];
    }
    sort(AA, AA+n);
    sort(BB, BB+m);
    FOR (i,0,n)
    {
        int pos = lower_bound(BB, BB+m, h - AA[i]) - BB;
        C[i] = m - pos;
        //cout << AA[i] << ' ' << C[i] << endl;
        I[i] = lower_bound(AA, AA+n, A[i]) - AA;
    }
    int res = 0;
    FOR (i,0,n)
    {
        W[i] = M[i] = INF;
        D[i] = 0;
    }
    FOR (i,0,m)
        add(I[i]);
    for (int i = 0; i+m-1 < n; i++)
    {
        /*FOR (j,0,n)
            cout << W[j] << ' ';
        cout << endl;
        cout << endl;*/
        int f = get();
        //cout << f << endl;
        if (f >= 0)
            ++ res;
        del(I[i]);
        if (i+m < n)
            add(I[i+m]);

        /*VI T1;
        VI T2;
        FOR (j,0,m)
            T1.PB(A[i+j]);
        FOR (j,0,m)
            T2.PB(B[j]);
        sort(ALL(T1));
        sort(ALL(T2));
        bool ok = 1;
        FOR (i,0,SZ(T1))
        {
            int pos = lower_bound(ALL(T2), h - T1[i]) - T2.begin();
            int cnt = m - pos;
            if (cnt < i+1)
                ok = 0;
        }
        res += ok;*/
    }
    printf("%d\n", res);

    return 0;
}


#pragma comment (linker, "/STACK:100000000")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define FILL(A,value) memset(A,value,sizeof(A))
#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair

typedef long long Int;
typedef vector <int> VI;
typedef pair <int, int> PII;

const int INF = 1000000000;
const int MAX = 1<<19;
const int MAX2 = 1<<18;

#define MOD 1000000009
#define K 300

int n, m, h;
int A[MAX];
int B[MAX];
int AA[MAX];
int BB[MAX];
int I[MAX];
int C[MAX];

int D[MAX];
int W[MAX];
int M[MAX];

int Cnt[MAX];

void upd(int x)
{
    int m = INF;
    FOR (i,x*K,x*K+K)
    {
        W[i] += D[x];
        m = min(m, W[i]);
    }
    M[x] = m;
    D[x] = 0;
}

void add(int l, int r, int d)
{
    while (l <= r)
        if ((l % K == 0) && (l+K-1 <= r))
        {
            if (D[l] < INF)
                D[l] += d;
            l += K;
        }
        else
        {
            if (W[l] < INF)
            {
                W[l] += d;
            }
            if (l == 0 || l == r)
                upd(l / K);
            l ++;
        }
}

void add(int x)
{
    W[x] = (Cnt[x] == 0 ? C[x] : W[x]);
    upd(x / K);
    add(x, n-1, -1);
    ++ Cnt[x];
}

void del(int x)
{
    add(x, n-1, 1);
    -- Cnt[x];
    W[x] = (Cnt[x] == 0 ? INF : C[x]);
    upd(x / K);
}

int get()
{
    int res = INF;
    for (int i = 0; i < n; i += K)
    {
        if (i+K-1 < n)
            res = min(res, M[i/K] + D[i/K]);
        else
        {
            FOR (j,i,n)
                res = min(res, W[j] + D[j/K]);
        }
    }
    return res;
}

int main()
{
    scanf("%d %d %d", &n, &m, &h);
    FOR (i,0,m)
    {
        scanf("%d", &B[i]);
        BB[i] = B[i];
    }
    FOR (i,0,n)
    {
        scanf("%d", &A[i]);
        AA[i] = A[i];
    }
    sort(AA, AA+n);
    sort(BB, BB+m);
    FOR (i,0,n)
    {
        int pos = lower_bound(BB, BB+m, h - AA[i]) - BB;
        C[i] = m - pos;
        //cout << AA[i] << ' ' << C[i] << endl;
        I[i] = lower_bound(AA, AA+n, AA[i]) - AA;
    }
    int res = 0;
    FOR (i,0,n)
    {
        W[i] = M[i] = INF;
        D[i] = 0;
    }
    FOR (i,0,m)
        add(I[i]);
    for (int i = 0; i+m-1 < n; i++)
    {
        /*FOR (j,0,n)
            cout << W[j] << ' ';
        cout << endl;
        cout << endl;*/
        int f = get();
        //cout << f << endl;
        if (f >= 0)
            ++ res;
        del(I[i]);
        if (i+m < n)
            add(I[i+m]);
    }
    printf("%d\n", res);

    return 0;
}


#pragma comment (linker, "/STACK:100000000")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define FILL(A,value) memset(A,value,sizeof(A))
#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair

typedef long long Int;
typedef vector <int> VI;
typedef pair <int, int> PII;

const int INF = 1000000000;
const int MAX = 1<<19;
const int MAX2 = 1<<18;

#define MOD 1000000009
#define K 300

int n, m, h;
int A[MAX];
int B[MAX];
int AA[MAX];
int BB[MAX];
int I[MAX];
int C[MAX];

int D[MAX];
int W[MAX];
int M[MAX];

int Cnt[MAX];

void upd(int x)
{
    int m = INF;
    FOR (i,x*K,x*K+K)
    {
        W[i] += D[x];
        m = min(m, W[i]);
    }
    M[x] = m;
    D[x] = 0;
}

void add(int l, int r, int d)
{
    while (l <= r)
        if ((l % K == 0) && (l+K-1 <= r))
        {
            if (D[l] < INF)
                D[l] += d;
            l += K;
        }
        else
        {
            if (W[l] < INF)
            {
                W[l] += d;
            }
            if (l == 0 || l == r)
                upd(l / K);
            l ++;
        }
}

void add(int x)
{
    W[x] = (Cnt[x] == 0 ? C[x] : W[x]);
    upd(x / K);
    add(x, n-1, -1);
    ++ Cnt[x];
}

void del(int x)
{
    add(x, n-1, 1);
    -- Cnt[x];
    W[x] = (Cnt[x] == 0 ? INF : C[x]);
    upd(x / K);
}

int get()
{
    int res = INF;
    for (int i = 0; i < n; i += K)
    {
        if (i+K-1 < n)
            res = min(res, M[i/K] + D[i/K]);
        else
        {
            FOR (j,i,n)
                res = min(res, W[j] + D[j/K]);
        }
    }
    return res;
}

int main()
{
    scanf("%d %d %d", &n, &m, &h);
    FOR (i,0,m)
    {
        scanf("%d", &B[i]);
        BB[i] = B[i];
    }
    FOR (i,0,n)
    {
        scanf("%d", &A[i]);
        AA[i] = A[i];
    }
    sort(AA, AA+n);
    sort(BB, BB+m);
    FOR (i,0,n)
    {
        int pos = lower_bound(BB, BB+m, h - AA[i]) - BB;
        C[i] = m - pos;
        //cout << AA[i] << ' ' << C[i] << endl;
        I[i] = lower_bound(AA, AA+n, A[i]) - AA;
    }
    int res = 0;
    FOR (i,0,n)
    {
        W[i] = M[i] = INF;
        D[i] = 0;
    }
    FOR (i,0,m)
        add(I[i]);
    for (int i = 0; i+m-1 < n; i++)
    {
        /*FOR (j,0,n)
            cout << W[j] << ' ';
        cout << endl;
        cout << endl;*/
        int f = get();
        //cout << f << endl;
        if (f >= 0)
            ++ res;
        del(I[i]);
        if (i+m < n)
            add(I[i+m]);
    }
    printf("%d\n", res);

    return 0;
}


#pragma comment (linker,  "/STACK:100000000")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define FILL(A,value) memset(A,value,sizeof(A))
#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair

typedef long long Int;
typedef vector <int> VI;
typedef pair <int, int> PII;

const int INF = 1000000000;
const int MAX = 1<<19;
const int MAX2 = 1<<18;

#define MOD 1000000009
#define K 300

int n, m, h;
int A[MAX];
int B[MAX];
int AA[MAX];
int BB[MAX];
int I[MAX];
int C[MAX];

int D[MAX];
int W[MAX];
int M[MAX];

int Cnt[MAX];

void upd(int x)
{
    int m = INF;
    FOR (i,x*K,x*K+K)
    {
        W[i] += D[x];
        m = min(m, W[i]);
    }
    M[x] = m;
    D[x] = 0;
}

void add(int l, int r, int d)
{
    int ll = l;
    while (l <= r)
        if ((l % K == 0) && (l+K-1 <= r))
        {
            D[l / K] += d;
            l += K;
        }
        else
        {
            W[l] += d;
            if (((l+1) % K == 0) || l == r)
                upd(l / K);
            l ++;
        }
}

void add(int x)
{
    W[x] = (Cnt[x] == 0 ? W[x] - INF + C[x] : W[x]);
    upd(x / K);
    add(x, n-1, -1);
    ++ Cnt[x];
}

void del(int x)
{
    add(x, n-1, 1);
    -- Cnt[x];
    W[x] = (Cnt[x] == 0 ? W[x] - C[x] + INF : W[x]);
    upd(x / K);
}

int get()
{
    int res = INF;
    for (int i = 0; i < n; i += K)
    {
        if (i+K-1 < n)
            res = min(res, M[i/K] + D[i/K]);
        else
        {
            FOR (j,i,n)
                res = min(res, W[j] + D[j/K]);
        }
    }
    return res;
}

int main()
{
    scanf("%d %d %d", &n, &m, &h);
    FOR (i,0,m)
    {
        scanf("%d", &B[i]);
        BB[i] = B[i];
    }
    FOR (i,0,n)
    {
        scanf("%d", &A[i]);
        AA[i] = A[i];
    }
    sort(AA, AA+n);
    sort(BB, BB+m);
    FOR (i,0,n)
    {
        int pos = lower_bound(BB, BB+m, h - AA[i]) - BB;
        C[i] = m - pos;
        //cout << AA[i] << ' ' << C[i] << endl;
        I[i] = lower_bound(AA, AA+n, A[i]) - AA;
    }
    int res = 0;
    FOR (i,0,n)
    {
        W[i] = M[i] = INF;
        D[i] = 0;
    }
    FOR (i,0,m)
        add(I[i]);
    for (int i = 0; i+m-1 < n; i++)
    {
        /*FOR (j,0,n)
            cout << W[j] << ' ';
        cout << endl;
        cout << endl;*/
        int f = get();
        //cout << f << endl;
        if (f >= 0)
            ++ res;
        del(I[i]);
        if (i+m < n)
            add(I[i+m]);

        /*VI T1;
        VI T2;
        FOR (j,0,m)
            T1.PB(A[i+j]);
        FOR (j,0,m)
            T2.PB(B[j]);
        sort(ALL(T1));
        sort(ALL(T2));
        bool ok = 1;
        FOR (i,0,SZ(T1))
        {
            int pos = lower_bound(ALL(T2), h - T1[i]) - T2.begin();
            int cnt = m - pos;
            if (cnt < i+1)
                ok = 0;
        }
        res += ok;*/
    }
    printf("%d\n", res);

    return 0;
}


#pragma comment (linker, "/STACK:100000000")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define FILL(A,value) memset(A,value,sizeof(A))
#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair

typedef long long Int;
typedef vector <int> VI;
typedef pair <int, int> PII;

const int INF = 1000000000;
const int MAX = 1<<19;
const int MAX2 = 1<<18;

#define MOD 1000000009
#define K 300

int n, m, h;
int A[MAX];
int B[MAX];
int AA[MAX];
int BB[MAX];
int I[MAX];
int C[MAX];

int D[MAX];
int W[MAX];
int M[MAX];

int Cnt[MAX];

void upd(int x)
{
    int m = INF;
    FOR (i,x*K,x*K+K)
    {
        W[i] += D[x];
        m = min(m, W[i]);
    }
    M[x] = m;
    D[x] = 0;
}

void add(int l, int r, int d)
{
    while (l <= r)
        if ((l % K == 0) && (l+K-1 <= r))
        {
            if (D[l] < INF)
                D[l] += d;
            l += K;
        }
        else
        {
            if (W[l] < INF)
            {
                W[l] += d;
            }
            if (l == 0 || l == r)
                upd(l / K);
            l ++;
        }
}

void add(int x)
{
    if (Cnt[x] == 0)
    {
        W[x] = C[x];
        upd(x / K);
    }
    add(x, n-1, -1);
    ++ Cnt[x];
}

void del(int x)
{
    add(x, n-1, 1);
    -- Cnt[x];
    if (Cnt[x] == 0)
    {
        W[x] = INF;
        upd(x / K);
    }
}

int get()
{
    int res = INF;
    for (int i = 0; i < n; i += K)
    {
        if (i+K-1 < n)
            res = min(res, M[i/K] + D[i/K]);
        else
        {
            FOR (j,i,n)
                res = min(res, W[j] + D[j/K]);
        }
    }
    return res;
}

int main()
{
    scanf("%d %d %d", &n, &m, &h);
    FOR (i,0,m)
    {
        scanf("%d", &B[i]);
        BB[i] = B[i];
    }
    FOR (i,0,n)
    {
        scanf("%d", &A[i]);
        AA[i] = A[i];
    }
    sort(AA, AA+n);
    sort(BB, BB+m);
    FOR (i,0,n)
    {
        int pos = lower_bound(BB, BB+m, h - AA[i]) - BB;
        C[i] = m - pos;
        I[i] = lower_bound(AA, AA+n, A[i]) - AA;
    }
    int res = 0;
    FOR (i,0,n)
    {
        W[i] = M[i] = INF;
        D[i] = 0;
    }
    FOR (i,0,m)
        add(I[i]);
    for (int i = 0; i+m-1 < n; i++)
    {
        int f = get();
        if (f >= 0)
            ++ res;
        del(I[i]);
        if (i+m < n)
            add(I[i+m]);
    }
    printf("%d\n", res);

    return 0;
}


#pragma comment (linker, "/STACK:100000000")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define FILL(A,value) memset(A,value,sizeof(A))
#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair

typedef long long Int;
typedef vector <int> VI;
typedef pair <int, int> PII;

const int INF = 1000000000;
const int MAX = 1<<19;
const int MAX2 = 1<<18;

#define MOD 1000000009
#define K 300

int n, m, h;
int A[MAX];
int B[MAX];
int AA[MAX];
int BB[MAX];
int I[MAX];
int C[MAX];

int D[MAX];
int W[MAX];
int M[MAX];

int Cnt[MAX];

void upd(int x)
{
    int m = INF;
    FOR (i,x*K,x*K+K)
    {
        W[i] += D[x];
        m = min(m, W[i]);
    }
    M[x] = m;
    D[x] = 0;
}

void add(int l, int r, int d)
{
    int ll = l;
    while (l <= r)
        if ((l % K == 0) && (l+K-1 <= r))
        {
            D[l / K] += d;
            l += K;
        }
        else
        {
            W[l] += d;
            if (((l+1) % K == 0) || l == r)
                upd(l / K);
            l ++;
        }
}

void add(int x)
{
    W[x] = (Cnt[x] == 0 ? W[x] - INF + C[x] : W[x]);
    upd(x / K);
    add(x, n-1, -1);
    ++ Cnt[x];
}

void del(int x)
{
    add(x, n-1, 1);
    -- Cnt[x];
    W[x] = (Cnt[x] == 0 ? W[x] - C[x] + INF : W[x]);
    upd(x / K);
}

int get()
{
    int res = INF;
    for (int i = 0; i < n; i += K)
    {
        if (i+K-1 < n)
            res = min(res, M[i/K] + D[i/K]);
        else
        {
            FOR (j,i,n)
                res = min(res, W[j] + D[j/K]);
        }
    }
    return res;
}

int main()
{
    scanf("%d %d %d", &n, &m, &h);
    FOR (i,0,m)
    {
        scanf("%d", &B[i]);
        BB[i] = B[i];
    }
    FOR (i,0,n)
    {
        scanf("%d", &A[i]);
        AA[i] = A[i];
    }
    sort(AA, AA+n);
    sort(BB, BB+m);
    FOR (i,0,n)
    {
        int pos = lower_bound(BB, BB+m, h - AA[i]) - BB;
        C[i] = m - pos;
        //cout << AA[i] << ' ' << C[i] << endl;
        I[i] = lower_bound(AA, AA+n, A[i]) - AA;
    }
    int res = 0;
    FOR (i,0,n)
    {
        W[i] = M[i] = INF;
        D[i] = 0;
    }
    FOR (i,0,m)
        add(I[i]);
    for (int i = 0; i+m-1 < n; i++)
    {
        /*FOR (j,0,n)
            cout << W[j] << ' ';
        cout << endl;
        cout << endl;*/
        int f = get();
        //cout << f << endl;
        if (f >= 0)
            ++ res;
        del(I[i]);
        if (i+m < n)
            add(I[i+m]);

        /*VI T1;
        VI T2;
        FOR (j,0,m)
            T1.PB(A[i+j]);
        FOR (j,0,m)
            T2.PB(B[j]);
        sort(ALL(T1));
        sort(ALL(T2));
        bool ok = 1;
        FOR (i,0,SZ(T1))
        {
            int pos = lower_bound(ALL(T2), h - T1[i]) - T2.begin();
            int cnt = m - pos;
            if (cnt < i+1)
                ok = 0;
        }
        res += ok;*/
    }
    printf("%d\n", res);

    return 0;
}


#pragma comment (linker, "/STACK:100000000")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define FILL(A,value) memset(A,value,sizeof(A))
#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair

typedef long long Int;
typedef vector <int> VI;
typedef pair <int, int> PII;

const int INF = 1000000000;
const int MAX = 1<<19;
const int MAX2 = 1<<18;

#define MOD 1000000009
#define K 300

int n, m, h;
int A[MAX];
int B[MAX];
int AA[MAX];
int BB[MAX];
int I[MAX];
int C[MAX];

int D[MAX];
int W[MAX];
int M[MAX];

int Cnt[MAX];

void upd(int x)
{
    int m = INF;
    FOR (i,x*K,x*K+K)
    {
        W[i] += D[x];
        m = min(m, W[i]);
    }
    M[x] = m;
    D[x] = 0;
}

void add(int l, int r, int d)
{
    int ll = l;
    while (l <= r)
        if ((l % K == 0) && (l+K-1 <= r))
        {
            if (D[l] < INF)
                D[l] += d;
            l += K;
        }
        else
        {
            W[l] += d;
            if (((l+1) % K == 0) || l == r)
                upd(l / K);
            l ++;
        }
}

void add(int x)
{
    W[x] = (Cnt[x] == 0 ? W[x] - INF + C[x] : W[x]);
    upd(x / K);
    add(x, n-1, -1);
    ++ Cnt[x];
}

void del(int x)
{
    add(x, n-1, 1);
    -- Cnt[x];
    W[x] = (Cnt[x] == 0 ? W[x] - C[x] + INF : W[x]);
    upd(x / K);
}

int get()
{
    int res = INF;
    for (int i = 0; i < n; i += K)
    {
        if (i+K-1 < n)
            res = min(res, M[i/K] + D[i/K]);
        else
        {
            FOR (j,i,n)
                res = min(res, W[j] + D[j/K]);
        }
    }
    return res;
}

int main()
{
    scanf("%d %d %d", &n, &m, &h);
    FOR (i,0,m)
    {
        scanf("%d", &B[i]);
        BB[i] = B[i];
    }
    FOR (i,0,n)
    {
        scanf("%d", &A[i]);
        AA[i] = A[i];
    }
    sort(AA, AA+n);
    sort(BB, BB+m);
    FOR (i,0,n)
    {
        int pos = lower_bound(BB, BB+m, h - AA[i]) - BB;
        C[i] = m - pos;
        //cout << AA[i] << ' ' << C[i] << endl;
        I[i] = lower_bound(AA, AA+n, A[i]) - AA;
    }
    int res = 0;
    FOR (i,0,n)
    {
        W[i] = M[i] = INF;
        D[i] = 0;
    }
    FOR (i,0,m)
        add(I[i]);
    for (int i = 0; i+m-1 < n; i++)
    {
        /*FOR (j,0,n)
            cout << W[j] << ' ';
        cout << endl;
        cout << endl;*/
        int f = get();
        //cout << f << endl;
        if (f >= 0)
            ++ res;
        del(I[i]);
        if (i+m < n)
            add(I[i+m]);

        /*VI T1;
        VI T2;
        FOR (j,0,m)
            T1.PB(A[i+j]);
        FOR (j,0,m)
            T2.PB(B[j]);
        sort(ALL(T1));
        sort(ALL(T2));
        bool ok = 1;
        FOR (i,0,SZ(T1))
        {
            int pos = lower_bound(ALL(T2), h - T1[i]) - T2.begin();
            int cnt = m - pos;
            if (cnt < i+1)
                ok = 0;
        }
        res += ok;*/
    }
    printf("%d\n", res);

    return 0;
}


#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
#define SIZE 262144
typedef long long ll;
ll INF = 1000000000000000000LL;
class segtree
{
public:
	ll seg[SIZE * 2];
	ll flag[SIZE * 2];
	void init()
	{
		fill(seg, seg + SIZE * 2, INF);
	}
	void update(int beg, int end, int node, int lb, int ub, ll num)
	{
		if (ub<beg || end<lb)return;
		if (beg <= lb&&ub <= end)
		{
			seg[node] += num;
			flag[node] += num;
			return;
		}
		if (flag[node])
		{
			seg[node * 2] += flag[node];
			seg[node * 2 + 1] += flag[node];
			flag[node * 2] += flag[node];
			flag[node * 2 + 1] += flag[node];
			flag[node] = 0;
		}
		update(beg, end, node * 2, lb, (lb + ub) / 2, num);
		update(beg, end, node * 2 + 1, (lb + ub) / 2 + 1, ub, num);
		seg[node] = min(seg[node * 2], seg[node * 2 + 1]);
	}
	ll get(int beg, int end, int node, int lb, int ub)
	{
		if (ub<beg || end<lb)return INF;
		if (beg <= lb&&ub <= end)
		{
			return seg[node];
		}
		if (flag[node])
		{
			seg[node * 2] += flag[node];
			seg[node * 2 + 1] += flag[node];
			flag[node * 2] += flag[node];
			flag[node * 2 + 1] += flag[node];
			flag[node] = 0;
		}
		return min(get(beg, end, node * 2, lb, (lb + ub) / 2), get(beg, end, node * 2 + 1, (lb + ub) / 2 + 1, ub));
	}
};
class BIT
{
public:
	int bit[SIZE + 1];
	void add(int a, int b)
	{
		a++;
		for (;;)
		{
			bit[a] += b;
			a += a&-a;
			if (a > SIZE)return;
		}
	}
	int get(int a)
	{
		a++;
		int ret = 0;
		for (;;)
		{
			ret += bit[a];
			a -= a&-a;
			if (a == 0)return ret;
		}
	}
};
segtree tree;
ll da[150000], db[150000];
int gen[150000];
typedef pair<ll, ll>pii;
BIT bi;
void add(int i)
{
	tree.update(da[i], SIZE - 1, 1, 0, SIZE - 1, -1);
	ll z = tree.get(da[i], da[i], 1, 0, SIZE - 1);
	int c = bi.get(da[i]);
	tree.update(da[i], da[i], 1, 0, SIZE - 1, -z + gen[i] - c);
	bi.add(da[i], 1);
}
void del(int i)
{
	tree.update(da[i], SIZE - 1, 1, 0, SIZE - 1, 1);
	ll z = tree.get(da[i], da[i], 1, 0, SIZE - 1);
	tree.update(da[i], da[i], 1, 0, SIZE - 1, -z + INF);
	bi.add(da[i], -1);
}
int main()
{
	int na, nb;
	ll hhh;
	scanf("%d%d%I64d", &na, &nb, &hhh);
	for (int i = 0; i < nb; i++)scanf("%I64d", &db[i]), db[i] = hhh - db[i];
	vector<pii>zat;
	for (int i = 0; i < na; i++)scanf("%I64d", &da[i]), zat.push_back(make_pair(da[i], i));
	sort(db, db + nb);
	sort(zat.begin(), zat.end());
	for (int i = 0; i < na; i++)
	{
		int low = lower_bound(zat.begin(), zat.end(), make_pair(da[i], (ll)i)) - zat.begin();
		gen[i] = upper_bound(db, db + nb, da[i]) - db - 1;
		da[i] = low;
	}
	tree.init();
	int ans = 0;
	for (int i = 0; i < nb; i++)add(i);
	for (int i = nb; i <= na; i++)
	{
		if (tree.get(0, SIZE - 1, 1, 0, SIZE - 1) >= 0)ans++;
		if (i != na)
		{
			add(i);
			del(i - nb);
		}
	}
	printf("%d\n", ans);
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define LL __int64
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
using namespace std;
const int MAXN = 150000;
const int INF = 0x3f3f3f3f;

LL b[MAXN],a[MAXN];
LL add[MAXN<<4],Max[MAXN<<4],mark[MAXN<<4];
LL x[MAXN],y[MAXN],sum[MAXN];
LL N,Len,H;
int find_x(int val,LL arr[]){
    int p=lower_bound(arr,arr+Len+1,val)-arr;
    if(p>=0&&p<=Len) return p;
    if(p>Len) return Len;
}
void preprocess(){
    sort(b+1,b+Len+1);
    memset(x,0,sizeof(x));
    memset(y,0,sizeof(y));
    memset(sum,0,sizeof(sum));
    for(int i=1;i<=Len;i++){
        if(a[i]+b[Len]<H) y[Len]+=INF;
        else if(a[i]>=H) continue;
        else{
            x[i]=find_x(H-a[i],b);
            y[x[i]]++;
        }
    }
    for(int i=Len;i>=1;i--)
        sum[i]=sum[i+1]+y[i];
}
void PushUp(int rt){
    Max[rt]=max(Max[rt<<1],Max[rt<<1|1]);
}
void PushDown(int rt){
    if(mark[rt]){
        mark[rt<<1]=mark[rt<<1|1]=mark[rt];
        add[rt<<1]=add[rt<<1|1]=add[rt];
        Max[rt<<1]+=add[rt];Max[rt<<1|1]+=add[rt];
        add[rt]=0;mark[rt]=false;
    }
}
void build(int l,int r,int rt){
    mark[rt]=false;add[rt]=0;
    if(l==r){
        Max[rt]=Len+1-l-sum[l];
        return;
    }
    int mid=(l+r)>>1;
    build(lson);
    build(rson);
    PushUp(rt);
}
void update(int L,int R,int val,int l,int r,int rt){
    if(L<=l&&r<=R){
        mark[rt]=true;
        add[rt]+=val;
        Max[rt]+=val;
        return;
    }
    PushDown(rt);
    int mid=(l+r)>>1;
    if(L<=mid) update(L,R,val,lson);
    if(mid<R) update(L,R,val,rson);
    PushUp(rt);
}
int main()
{
  //  freopen("test.txt","r",stdin);
    while(cin>>N>>Len>>H){
        for(int i=1;i<=Len;i++) cin>>b[i];
        for(int i=1;i<=N;i++) cin>>a[i];
        preprocess();
        build(1,Len,1);
        int ans=0;
        if(Max[1]>=0) ans++;
        for(int i=Len+1;i<=N;i++){
            if(a[i-Len]+b[Len]<H) update(1,Len,INF,1,Len,1);
            else if(a[i-Len]<H){
                int tmp=find_x(H-a[i-Len],b);
                update(1,tmp,1,1,Len,1);
            }
            if(a[i]+b[Len]<H) update(1,Len,-INF,1,Len,1);
            else if(a[i]<H){
                x[i]=find_x(H-a[i],b);
                update(1,x[i],-1,1,Len,1);
            }
            if(Max[1]>=0) ans++;
        }
        cout<<ans<<endl;
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define LL __int64
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
using namespace std;
const int MAXN = 150000;
int INF = 0x3f3f3f3f;

LL b[MAXN],a[MAXN];
LL add[MAXN<<4],Max[MAXN<<4],mark[MAXN<<4];
LL x[MAXN],y[MAXN],sum[MAXN];
int N,Len,H;
int find_x(int val,LL arr[]){
    int p=lower_bound(arr,arr+Len+1,val)-arr;
    if(p>=0&&p<=Len) return p;
    if(p>Len) return Len;
}
void preprocess(){
    sort(b+1,b+Len+1);
    memset(x,0,sizeof(x));
    memset(y,0,sizeof(y));
    memset(sum,0,sizeof(sum));
    for(int i=1;i<=Len;i++){
        if(a[i]+b[Len]<H) y[Len]+=INF;
        else{
            x[i]=find_x(H-a[i],b);
            y[x[i]]++;
        }
    }
    for(int i=Len;i>=1;i--)
        sum[i]=sum[i+1]+y[i];
}
void PushUp(int rt){
    Max[rt]=max(Max[rt<<1],Max[rt<<1|1]);
}
void PushDown(int rt){
    if(mark[rt]){
        mark[rt<<1]=mark[rt<<1|1]=mark[rt];
        add[rt<<1]=add[rt<<1|1]=add[rt];
        Max[rt<<1]+=add[rt];Max[rt<<1|1]+=add[rt];
        add[rt]=0;mark[rt]=false;
    }
}
void build(int l,int r,int rt){
    mark[rt]=false;add[rt]=0;
    if(l==r){
        Max[rt]=l+sum[l];
        return;
    }
    int mid=(l+r)>>1;
    build(lson);
    build(rson);
    PushUp(rt);
}
void update(int L,int R,int val,int l,int r,int rt){
    if(L<=l&&r<=R){
        mark[rt]=true;
        add[rt]+=val;
        Max[rt]+=val;
        return;
    }
    PushDown(rt);
    int mid=(l+r)>>1;
    if(L<=mid) update(L,R,val,lson);
    if(mid<R) update(L,R,val,rson);
    PushUp(rt);
}
int main()
{
 //   freopen("test.txt","r",stdin);
    while(cin>>N>>Len>>H){
        INF = N;
        for(int i=1;i<=Len;i++) cin>>b[i];
        for(int i=1;i<=N;i++) cin>>a[i];
        preprocess();
        build(1,Len,1);
        int ans=0;
        if(Max[1]<=Len+1) ans++;
        for(int i=Len+1;i<=N;i++){
            if(a[i-Len]+b[Len]<H) update(1,Len,-INF,1,Len,1);
            else{
                int tmp=find_x(H-a[i-Len],b);
                update(1,tmp,-1,1,Len,1);
            }
            if(a[i]+b[Len]<H) update(1,Len,INF,1,Len,1);
            else{
                x[i]=find_x(H-a[i],b);
                update(1,x[i],1,1,Len,1);
            }
            if(Max[1]<=Len+1) ans++;

        }
        cout<<ans<<endl;
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define LL __int64
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
using namespace std;
const int MAXN = 150000;
const int INF = 0x3f3f3f3f;

LL b[MAXN],a[MAXN];
LL add[MAXN<<4],Max[MAXN<<4],mark[MAXN<<4];
LL x[MAXN],y[MAXN],sum[MAXN];
LL N,Len,H;
int find_x(int val,LL arr[]){
    int p=lower_bound(arr,arr+Len+1,val)-arr;
    if(p>=0&&p<=Len) return p;
    if(p>Len) return Len;
}
void preprocess(){
    sort(b+1,b+Len+1);
    memset(x,0,sizeof(x));
    memset(y,0,sizeof(y));
    memset(sum,0,sizeof(sum));
    for(int i=1;i<=Len;i++){
        if(a[i]+b[Len]<H) y[Len]+=INF;
        else if(a[i]>=H) continue;
        else{
            x[i]=find_x(H-a[i],b);
            y[x[i]]++;
        }
    }
    for(int i=Len;i>=1;i--)
        sum[i]=sum[i+1]+y[i];
}
void PushUp(int rt){
    Max[rt]=max(Max[rt<<1],Max[rt<<1|1]);
}
void PushDown(int rt){
    if(mark[rt]){
        mark[rt<<1]=mark[rt<<1|1]=mark[rt];
        add[rt<<1]=add[rt<<1|1]=add[rt];
        Max[rt<<1]+=add[rt];Max[rt<<1|1]+=add[rt];
        add[rt]=0;mark[rt]=false;
    }
}
void build(int l,int r,int rt){
    mark[rt]=false;add[rt]=0;
    if(l==r){
        Max[rt]=l+sum[l];
        return;
    }
    int mid=(l+r)>>1;
    build(lson);
    build(rson);
    PushUp(rt);
}
void update(int L,int R,int val,int l,int r,int rt){
    if(L<=l&&r<=R){
        mark[rt]=true;
        add[rt]+=val;
        Max[rt]+=val;
        return;
    }
    PushDown(rt);
    int mid=(l+r)>>1;
    if(L<=mid) update(L,R,val,lson);
    if(mid<R) update(L,R,val,rson);
    PushUp(rt);
}
int main()
{
 //   freopen("test.txt","r",stdin);
    while(cin>>N>>Len>>H){
  //      INF = N;
        for(int i=1;i<=Len;i++) cin>>b[i];
        for(int i=1;i<=N;i++) cin>>a[i];
        preprocess();
        build(1,Len,1);
        int ans=0;
        if(Max[1]<=Len+1) ans++;
        for(int i=Len+1;i<=N;i++){
            if(a[i-Len]+b[Len]<H) update(1,Len,-INF,1,Len,1);
            else if(a[i-Len]<H){
                int tmp=find_x(H-a[i-Len],b);
                update(1,tmp,-1,1,Len,1);
            }
            if(a[i]+b[Len]<H) update(1,Len,INF,1,Len,1);
            else if(a[i]<H){
                x[i]=find_x(H-a[i],b);
                update(1,x[i],1,1,Len,1);
            }
            if(Max[1]<=Len+1) ans++;
        }
        cout<<ans<<endl;
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define LL __int64
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
using namespace std;
const int MAXN = 150000;
const int INF = 0x3f3f3f3f;

LL b[MAXN],a[MAXN];
LL add[MAXN<<4],Max[MAXN<<4],mark[MAXN<<4];
LL x[MAXN],y[MAXN],sum[MAXN];
int N,Len,H;
int find_x(int val,LL arr[]){
    int p=lower_bound(arr,arr+Len+1,val)-arr;
    if(p>=0&&p<=Len) return p;
    if(p>Len) return Len;
}
void preprocess(){
    sort(b+1,b+Len+1);
    memset(x,0,sizeof(x));
    memset(y,0,sizeof(y));
    memset(sum,0,sizeof(sum));
    for(int i=1;i<=Len;i++){
        if(a[i]+b[Len]<H) y[Len]+=INF;
        else if(a[i]>=H) continue;
        else{
            x[i]=find_x(H-a[i],b);
            y[x[i]]++;
        }
    }
    for(int i=Len;i>=1;i--)
        sum[i]=sum[i+1]+y[i];
}
void PushUp(int rt){
    Max[rt]=max(Max[rt<<1],Max[rt<<1|1]);
}
void PushDown(int rt){
    if(mark[rt]){
        mark[rt<<1]=mark[rt<<1|1]=mark[rt];
        add[rt<<1]=add[rt<<1|1]=add[rt];
        Max[rt<<1]+=add[rt];Max[rt<<1|1]+=add[rt];
        add[rt]=0;mark[rt]=false;
    }
}
void build(int l,int r,int rt){
    mark[rt]=false;add[rt]=0;
    if(l==r){
        Max[rt]=l+sum[l];
        return;
    }
    int mid=(l+r)>>1;
    build(lson);
    build(rson);
    PushUp(rt);
}
void update(int L,int R,int val,int l,int r,int rt){
    if(L<=l&&r<=R){
        mark[rt]=true;
        add[rt]+=val;
        Max[rt]+=val;
        return;
    }
    PushDown(rt);
    int mid=(l+r)>>1;
    if(L<=mid) update(L,R,val,lson);
    if(mid<R) update(L,R,val,rson);
    PushUp(rt);
}
int main()
{
 //   freopen("test.txt","r",stdin);
    while(cin>>N>>Len>>H){
  //      INF = N;
        for(int i=1;i<=Len;i++) cin>>b[i];
        for(int i=1;i<=N;i++) cin>>a[i];
        preprocess();
        build(1,Len,1);
        int ans=0;
        if(Max[1]<=Len+1) ans++;
        for(int i=Len+1;i<=N;i++){
            if(a[i-Len]+b[Len]<H) update(1,Len,-INF,1,Len,1);
            else if(a[i-Len]<H){
                int tmp=find_x(H-a[i-Len],b);
                update(1,tmp,-1,1,Len,1);
            }
            if(a[i]+b[Len]<H) update(1,Len,INF,1,Len,1);
            else if(a[i]<H){
                x[i]=find_x(H-a[i],b);
                update(1,x[i],1,1,Len,1);
            }
            if(Max[1]<=Len+1) ans++;
        }
        cout<<ans<<endl;
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define LL __int64
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
using namespace std;
const int MAXN = 150000;
int INF = 0x3f3f3f3f;

LL b[MAXN],a[MAXN];
LL add[MAXN<<4],Max[MAXN<<4],mark[MAXN<<4];
LL x[MAXN],y[MAXN],sum[MAXN];
int N,Len,H;
int find_x(int val,LL arr[]){
    int p=lower_bound(arr,arr+Len+1,val)-arr;
    if(p>=0&&p<=Len) return p;
    if(p>Len) return Len;
}
void preprocess(){
    sort(b+1,b+Len+1);
    memset(x,0,sizeof(x));
    memset(y,0,sizeof(y));
    memset(sum,0,sizeof(sum));
    for(int i=1;i<=Len;i++){
        if(a[i]+b[Len]<H) y[Len]+=INF;
        else if(a[i]>=H) continue;
        else{
            x[i]=find_x(H-a[i],b);
            y[x[i]]++;
        }
    }
    for(int i=Len;i>=1;i--)
        sum[i]=sum[i+1]+y[i];
}
void PushUp(int rt){
    Max[rt]=max(Max[rt<<1],Max[rt<<1|1]);
}
void PushDown(int rt){
    if(mark[rt]){
        mark[rt<<1]=mark[rt<<1|1]=mark[rt];
        add[rt<<1]=add[rt<<1|1]=add[rt];
        Max[rt<<1]+=add[rt];Max[rt<<1|1]+=add[rt];
        add[rt]=0;mark[rt]=false;
    }
}
void build(int l,int r,int rt){
    mark[rt]=false;add[rt]=0;
    if(l==r){
        Max[rt]=l+sum[l];
        return;
    }
    int mid=(l+r)>>1;
    build(lson);
    build(rson);
    PushUp(rt);
}
void update(int L,int R,int val,int l,int r,int rt){
    if(L<=l&&r<=R){
        mark[rt]=true;
        add[rt]+=val;
        Max[rt]+=val;
        return;
    }
    PushDown(rt);
    int mid=(l+r)>>1;
    if(L<=mid) update(L,R,val,lson);
    if(mid<R) update(L,R,val,rson);
    PushUp(rt);
}
int main()
{
  //  freopen("test.txt","r",stdin);
    while(cin>>N>>Len>>H){
        INF = N;
        for(int i=1;i<=Len;i++) cin>>b[i];
        for(int i=1;i<=N;i++) cin>>a[i];
        preprocess();
        build(1,Len,1);
        int ans=0;
        if(Max[1]<=Len+1) ans++;
        for(int i=Len+1;i<=N;i++){
            if(a[i-Len]+b[Len]<H) update(1,Len,-INF,1,Len,1);
            else if(a[i-Len]<H){
                int tmp=find_x(H-a[i-Len],b);
                update(1,tmp,-1,1,Len,1);
            }
            if(a[i]+b[Len]<H) update(1,Len,INF,1,Len,1);
            else if(a[i]<H){
                x[i]=find_x(H-a[i],b);
                update(1,x[i],1,1,Len,1);
            }
            if(Max[1]<=Len+1) ans++;

        }
        cout<<ans<<endl;
    }
    return 0;
}


#include <cstdio>
#include <algorithm>
const int N = 150000 + 9;
int a[N],min[N*4],tag[N*4],b[N],n,len,h,L,R,D;
inline void push_up(const int idx)
{min[idx] = std::min(min[idx * 2], min[idx * 2 + 1]);}
inline void push_down(const int idx)
{
    if (!tag[idx]) return;
    tag[idx * 2] += tag[idx]; tag[idx * 2 + 1] += tag[idx];
    min[idx * 2] += tag[idx]; min[idx * 2 + 1] += tag[idx];
    tag[idx] = 0;
}
void modify(const int idx,const int l,const int r)
{
    if (L <= l && r <= R) return (void)(min[idx] += D,tag[idx] += D);
    const int mid = (l + r) / 2;
    if (tag[idx]) push_down(idx);
    if (L <= mid) modify(idx * 2, l, mid);
    if (mid < R) modify(idx * 2 + 1, mid + 1, r);
    push_up(idx);
}
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("E.in","r",stdin);
    freopen("E.out","w",stdout);
    #endif
    scanf("%d%d%d",&n,&len,&h);
    for (int i = 1; i <= len; ++i) {
        scanf("%d",b + i);
        L = R = i;
        D = len - i + 1;
        modify(1,1,len);
    }
    for (int i = 1; i <= n; ++i) {scanf("%d",a + i); a[i] = h - a[i];}
    std::sort(b + 1, b + 1 + len);
    int cnt = 0,ans = 0;
    for (int i = 1; i <= len; ++i) {
        if (a[i] > b[len]) {++cnt;continue;}
        if (i != 1 && a[i] <= 0) continue;
        L = 1; R = std::lower_bound(b + 1, b + 1 + len,a[i]) - b; D = -1;
        modify(1,1,len);
    }
    if (!cnt && min[1] >= 0) ++ans;
    for (int i = len + 1; i <= n; ++i) {
        if (a[i - len] <= b[len]) {
            L = 1; R = std::lower_bound(b + 1, b + 1 + len,a[i - len]) - b; D = 1;
            modify(1,1,len);
        }else --cnt;

        if (a[i - len + 1] <= 0) {
            L = 1; R = std::lower_bound(b + 1, b + 1 + len,a[i - len + 1]) - b; D = -1;
            modify(1,1,len);
        }

        if (a[i] > b[len]) {++cnt;continue;}
        if (a[i] > 0) {
            L = 1; R = std::lower_bound(b + 1, b + 1 + len,a[i]) - b; D = -1;
            modify(1,1,len);
        }

        if (!cnt && min[1] >= 0) ++ans;
    }
    printf("%d\n",ans);
}


#include<cstring>
#include<cstdlib>
#include<iostream>
#include<stdio.h>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
#define N 150010
#define MOD 1000000009
#define LL long long

int a[N];
int b[N];
int c[N*4];
int p[N];

int n,m,k;

void change(int l,int r,int tt,int k,int x)
{
    if(l==r)
    {
        c[tt]+=x;
        return ;
    }
    int mid=(l+r)/2;
    if(k>mid)
    {
        change(mid+1,r,tt*2+1,k,x);
    }
    else
    {
        change(l,mid,tt*2,k,x);
    }
    c[tt]=c[tt*2]+c[tt*2+1];
}

int query(int l,int r,int x,int y,int tt)
{
    if(l==x&&r==y) return c[tt];
    int mid=(l+r)/2;
    if(x>mid)
    {
        return query(mid+1,r,x,y,tt*2+1);
    }
    else if(y<=mid)
    {
        return query(l,mid,x,y,tt*2);
    }
    else
        return query(l,mid,x,mid,tt*2)+query(mid+1,r,mid+1,y,tt*2+1);
}

int fd(int x)
{
    int l=1,r=m,ret=m+1;
    while(l<=r)
    {
        int mid=(l+r)/2;
        if(x+a[mid]>=k)
        {
            ret=mid;
            r=mid-1;
        }
        else
        {
            l=mid+1;
        }
    }
    return ret;
}

bool judge()
{
    if(query(1,m,1,m,1)<m)
        return false;
    for(int i=0,j=1;j<m;i++,j=1<<i)
    {
        if(query(1,m,1,j,1)<j)
            return false;
    }
    return true;
}

int main()
{
    scanf("%d%d%d",&n,&m,&k);
    for(int i=1;i<=m;i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a+1,a+m+1);
    int ans=0,sum=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&b[i]);
        int x=fd(b[i]);
        p[i]=x;

        if(p[i]<=m)
            change(1,m,1,p[i],1);
        if(i>m)
        {
            if(p[i-m]<=m)
                change(1,m,1,p[i-m],-1);
        }
        ans+=judge();
    }
    printf("%d\n",ans);
    return 0;
}


#include<cstring>
#include<cstdlib>
#include<iostream>
#include<stdio.h>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
#define N 150010
#define MOD 1000000009
#define LL long long

int a[N];
int b[N];
int c[N*4];
int p[N*4];
int q[N*4];

int n,m,k;

void update(int tt)
{
    c[tt*2]+=p[tt];c[tt*2+1]+=p[tt];
    p[tt*2]+=p[tt];p[tt*2+1]+=p[tt];
    p[tt]=0;
}

void change(int l,int r,int tt,int x,int y,int k)
{
    if(l==x&&r==y)
    {
        c[tt]+=k;
        p[tt]+=k;
        return ;
    }
    update(tt);
    int mid=(l+r)/2;
    if(x>mid)change(mid+1,r,tt*2+1,x,y,k);
    else if(y<=mid)change(l,mid,tt*2,x,y,k);
    else
    {
        change(mid+1,r,tt*2+1,mid+1,y,k);
        change(l,mid,tt*2,x,mid,k);
    }
    c[tt]=min(c[tt*2],c[tt*2+1]);
}

int fd(int x)
{
    int l=1,r=m,ret=m+1;
    while(l<=r)
    {
        int mid=(l+r)/2;
        if(x+a[mid]>=k)
        {
            ret=mid;
            r=mid-1;
        }
        else
        {
            l=mid+1;
        }
    }
    return ret;
}

int main()
{
    scanf("%d%d%d",&n,&m,&k);
    for(int i=1;i<=m;i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a+1,a+m+1);
    for(int i=1;i<=m;i++) change(1,m,1,i,i,-i);
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&b[i]);
        q[i]=fd(b[i]);
        if(q[i]<=m)change(1,m,1,q[i],m,1);
        if(i>m&&q[i-m]<=m)change(1,m,1,q[i-m],m,-1);
        ans+=c[1]>=0;
    }
    printf("%d\n",ans);
    return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
const int N = 150005;
#define min(x,y) ((x)<(y)?(x):(y))
int a[N],b[N];
struct P
{
    int l,r,mid,key,add;
}arr[4*N];
void build(int L,int R,int c)
{
    arr[c].l=L;
    arr[c].r=R;
    arr[c].mid=(L+R)/2;
    if(L==R){arr[c].key=-L;return ;}
    build(L,arr[c].mid,c+c);
    build(arr[c].mid+1,R,c+c+1);
    arr[c].key=min(arr[c+c].key,arr[c+c+1].key);
}
void down(int c)
{
    if(arr[c].add)
    {
        arr[c+c].add+=arr[c].add;
        arr[c+c+1].add+=arr[c].add;
        arr[c].add=0;
    }
}
void insert(int x,int v,int c)
{
    if(x<=arr[c].l)
    {
        arr[c].add+=v;
        return ;
    }
    down(c);
    if(x<=arr[c].mid)insert(x,v,c+c);
    insert(x,v,c+c+1);
    arr[c].key=min(arr[c+c].key+arr[c+c].add,arr[c+c+1].key+arr[c+c+1].add);
}
int main()
{
    int n,m,h,i;
    scanf("%d%d%d",&n,&m,&h);
    for(i=1;i<=m;i++)
    {
        scanf("%d",&b[i]);
    }
    sort(b+1,b+m+1);
    for(i=1;i<=m;i++)printf("%d ",b[i]);puts("");
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    build(1,m,1);
    for(i=1;i<m;i++)
    {
        //printf("1key:%d \n",arr[1].key+arr[1].add);
        int p=lower_bound(b+1,b+m+1,h-a[i])-b;
        //printf("i:%d p:%d \n",i,p);
        if(p<=m)insert(p,1,1);
    }
    int ret=0;
    for(;i<=n;i++)
    {
        int p;
        if(i>m)
        {
            p=lower_bound(b+1,b+m+1,h-a[i-m])-b;
            if(p<=m)insert(p,-1,1);
        }
        p=lower_bound(b+1,b+m+1,h-a[i])-b;
        if(p<=m)insert(p,1,1);
        //printf("i:%d p:%d arr[1].key+arr[1].add:%d \n",i,p,arr[1].key+arr[1].add);
        if(arr[1].key+arr[1].add>=0)ret++;
    }
    printf("%d\n",ret);
    return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
const int N = 150005;
#define min(x,y) ((x)<(y)?(x):(y))
int a[N],b[N];
struct P
{
	int l,r,mid,key,add;
}arr[4*N];
void build(int L,int R,int c)
{
	arr[c].l=L;
	arr[c].r=R;
	arr[c].mid=(L+R)/2;
	if(L==R){arr[c].key=-L;return ;}
	build(L,arr[c].mid,c+c);
	build(arr[c].mid+1,R,c+c+1);
	arr[c].key=min(arr[c+c].key,arr[c+c+1].key);
}
void down(int c)
{
	if(arr[c].add)
	{
		arr[c+c].add+=arr[c].add;
		arr[c+c+1].add+=arr[c].add;
		arr[c].add=0;
	}
}
void insert(int x,int v,int c)
{
	if(x<=arr[c].l)
	{
		arr[c].add+=v;
		return ;
	}
	down(c);
	if(x<=arr[c].mid)insert(x,v,c+c);
	else insert(x,v,c+c+1);
	arr[c].key=min(arr[c+c].key+arr[c+c].add,arr[c+c+1].key+arr[c+c+1].add);
}
int main()
{
	int n,m,h,i;
	scanf("%d%d%d",&n,&m,&h);
	for(i=1;i<=m;i++)
	{
		scanf("%d",&b[i]);
	}
	sort(b+1,b+m+1);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	build(1,m,1);
	for(i=1;i<m;i++)
	{
		int p=lower_bound(b+1,b+m+1,h-a[i])-b;
		if(p<=m)insert(p,1,1);
	}
	int ret=0;
	for(;i<=n;i++)
	{
		int p;
		if(i>m)
		{
			p=lower_bound(b+1,b+m+1,h-a[i-m])-b;
			if(p<=m)insert(p,-1,1);
		}
		p=lower_bound(b+1,b+m+1,h-a[i])-b;
		if(p<=m)insert(p,1,1);
		if(arr[1].key+arr[1].add>=0)ret++;
	}
	printf("%d\n",ret);
	return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
const int N = 150005;
#define min(x,y) ((x)<(y)?(x):(y))
int a[N],b[N];
struct P
{
    int l,r,mid,key,add;
}arr[4*N];
void build(int L,int R,int c)
{
    arr[c].l=L;
    arr[c].r=R;
    arr[c].mid=(L+R)/2;
    if(L==R){arr[c].key=-L;return ;}
    build(L,arr[c].mid,c+c);
    build(arr[c].mid+1,R,c+c+1);
    arr[c].key=min(arr[c+c].key,arr[c+c+1].key);
}
void down(int c)
{
    if(arr[c].add)
    {
        arr[c+c].add+=arr[c].add;
        arr[c+c+1].add+=arr[c].add;
        arr[c].add=0;
    }
}
void insert(int x,int v,int c)
{
    if(x<=arr[c].l)
    {
        arr[c].add+=v;
        return ;
    }
    down(c);
    if(x<=arr[c].mid)insert(x,v,c+c);
    insert(x,v,c+c+1);
    arr[c].key=min(arr[c+c].key+arr[c+c].add,arr[c+c+1].key+arr[c+c+1].add);
}
int main()
{
    int n,m,h,i;
    scanf("%d%d%d",&n,&m,&h);
    for(i=1;i<=m;i++)
    {
        scanf("%d",&b[i]);
    }
    sort(b+1,b+m+1);
    //for(i=1;i<=m;i++)printf("%d ",b[i]);puts("");
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    build(1,m,1);
    for(i=1;i<m;i++)
    {
        //printf("1key:%d \n",arr[1].key+arr[1].add);
        int p=lower_bound(b+1,b+m+1,h-a[i])-b;
        //printf("i:%d p:%d \n",i,p);
        if(p<=m)insert(p,1,1);
    }
    int ret=0;
    for(;i<=n;i++)
    {
        int p;
        if(i>m)
        {
            p=lower_bound(b+1,b+m+1,h-a[i-m])-b;
            if(p<=m)insert(p,-1,1);
        }
        p=lower_bound(b+1,b+m+1,h-a[i])-b;
        if(p<=m)insert(p,1,1);
        //printf("i:%d p:%d arr[1].key+arr[1].add:%d \n",i,p,arr[1].key+arr[1].add);
        if(arr[1].key+arr[1].add>=0)ret++;
    }
    printf("%d\n",ret);
    return 0;
}


#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<math.h>
#include<time.h>
#include<vector>
#include<bitset>
#include<memory>
#include<utility>
#include<fstream>
#include<stdio.h>
#include<sstream>
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
using namespace std;
int a[150005];
int b[150005];
int val[1<<19];
int tag[1<<19];
int n,m,h;
void build_tree(int num,int l,int r)
{
    if (l==r-1)
    {
        val[num]=m-l;
        return;
    }
    int mid=(l+r)/2;
    build_tree(num*2+1,l,mid);
    build_tree(num*2+2,mid,r);
    val[num]=m-l;
}
void push_down(int num)
{
    if (tag[num]==0) return;
    val[num*2+1]+=tag[num];
    tag[num*2+1]+=tag[num];
    val[num*2+2]+=tag[num];
    tag[num*2+2]+=tag[num];
    tag[num]=0;
}
inline void change(int num,int l,int r,int l0,int r0,int t)
{
    if (l0==r0) return;
    if ((l0<=l)&&(r<=r0))
    {
        tag[num]+=t;
        val[num]+=t;
        return;
    }
    push_down(num);
    int mid=(l+r)/2;
    if (l0<mid) change(num*2+1,l,mid,l0,r0,t);
    if (mid<r0) change(num*2+2,mid,r,l0,r0,t);
    val[num]=max(val[num*2+1],val[num*2+2]);
}
inline int query()
{
    return val[0];
}
inline int numbers(int x)
{
    return upper_bound(b,b+m,x)-b;
}
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    scanf("%d%d%d",&n,&m,&h);
    int i;
    for (i=0;i<m;i++)
    {
        scanf("%d",&b[i]);
        b[i]=h-b[i];
    }
    for (i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    sort(b,b+m);
    build_tree(0,0,m);
    for (i=0;i<m;i++)
    {
        int t=numbers(a[i]);
        change(0,0,m,0,t,-1);
    }
    int ans=0;
    for (;i<=n;i++)
    {
        if (query()<=0)
        {
            ans++;
        }
        int x=i-m;
        int t=numbers(a[x]);
        change(0,0,m,0,t,1);
        t=numbers(a[i]);
        change(0,0,m,0,t,-1);
    }
    printf("%d\n",ans);
    return 0;
}


#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<math.h>
#include<time.h>
#include<vector>
#include<bitset>
#include<memory>
#include<utility>
#include<fstream>
#include<stdio.h>
#include<sstream>
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
using namespace std;
int a[150005];
int b[150005];
int val[1<<19];
int tag[1<<19];
int n,m,h;
void build_tree(int num,int l,int r)
{
    if (l==r-1)
    {
        val[num]=m-l;
        return;
    }
    int mid=(l+r)/2;
    build_tree(num*2+1,l,mid);
    build_tree(num*2+2,mid,r);
    val[num]=m-l;
}
void push_down(int num)
{
    if (tag[num]==0) return;
    val[num*2+1]+=tag[num];
    tag[num*2+1]+=tag[num];
    val[num*2+2]+=tag[num];
    tag[num*2+2]+=tag[num];
    tag[num]=0;
}
inline void change(int num,int l,int r,int l0,int r0,int t)
{
    if ((l0<=l)&&(r<=r0))
    {
        tag[num]+=t;
        val[num]+=t;
        return;
    }
    push_down(num);
    int mid=(l+r)/2;
    if (l0<mid) change(num*2+1,l,mid,l0,r0,t);
    if (mid<r0) change(num*2+2,mid,r,l0,r0,t);
    val[num]=max(val[num*2+1],val[num*2+2]);
}
inline int query()
{
    return val[0];
}
inline int numbers(int x)
{
    return upper_bound(b,b+m,x)-b;
}
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    scanf("%d%d%d",&n,&m,&h);
    int i;
    for (i=0;i<m;i++)
    {
        scanf("%d",&b[i]);
        b[i]=h-b[i];
    }
    for (i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    sort(b,b+m);
    build_tree(0,0,m);
    for (i=0;i<m-1;i++)
    {
        int t=numbers(a[i]);
        change(0,0,m,0,t,-1);
    }
    int ans=0;
    for (;i<=n;i++)
    {
        if (query()<=0)
        {
            ans++;
        }
        int x=i-(m-1);
        int t=numbers(a[x]);
        change(0,0,m,0,t,1);
        t=numbers(a[i]);
        change(0,0,m,0,t,-1);
    }
    printf("%d\n",ans);
    return 0;
}


#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;

#define __ const int m=l+r>>1
#define _0 (u<<1)
#define _1 (_0|1)

const int NMAX=150000;
const int MMAX=NMAX;

int N,M,H,P[MMAX],S[NMAX];
int Z; vector<int> V;

struct Node
{
	int ad;
	int mi;
} Tree[1048576];

int ql,qr,qx;

static inline void update(int u,int x)
{
	Tree[u].ad+=x;
	Tree[u].mi+=x;
}

void add(int u,int l,int r)
{
	if(ql<=l&&r<=qr){update(u,qx);return;}
	__;
	if(Tree[u].ad!=0)
	{
		update(_0,Tree[u].ad);
		update(_1,Tree[u].ad);
		Tree[u].ad=0;
	}
	if(ql<=m)add(_0,l  ,m);
	if(qr> m)add(_1,m+1,r);
	Tree[u].mi=min(Tree[_0].mi,Tree[_1].mi);
}

int solve()
{
	int ret=0;
	ql=0;
	qx=-1;
	for(int i=0;i<M;i++)
	{
		qr=P[i];
		add(1,0,Z-1);
	}
	qx=+1;
	for(int i=0;i<M;i++)
	{
		qr=S[i];
		add(1,0,Z-1);
	}
	if(Tree[1].mi>=0)ret++;
	for(int i=M;i<N;i++)
	{
		qr=S[i-M];
		qx=-1;
		add(1,0,Z-1);
		qr=S[i];
		qx=+1;
		add(1,0,Z-1);
		if(Tree[1].mi>=0)ret++;
	}
	return ret;
}

void input()
{
	cin>>N>>M>>H;
	for(int i=0;i<M;i++)
	{
		cin>>P[i];
		P[i]=H-P[i];
		V.push_back(P[i]);
	}
	for(int i=0;i<N;i++)
	{
		cin>>S[i];
		V.push_back(S[i]);
	}
	sort(V.begin(),V.end());
	V.resize(Z=unique(V.begin(),V.end())-V.begin());
	for(int i=0;i<M;i++)P[i]=lower_bound(V.begin(),V.end(),P[i])-V.begin();
	for(int i=0;i<N;i++)S[i]=lower_bound(V.begin(),V.end(),S[i])-V.begin();
}

int main()
{
	ios_base::sync_with_stdio(false);
	input();
	cout<<solve()<<endl;
	return 0;
}


#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <sstream>
using namespace std;
#pragma comment(linker, "/STACK:255000000")

typedef long long ll;

#define rep(i, a, b) for(i = (a); i < (b); ++i)
#define repb(i, a, b) for(i = (a) - 1; i >= (b); --i)
#define repd(i, a, b, d) for(i = (a); i < (b); i += (d))
#define repbd(i, a, b, d) for(i = (a) - 1; i >= (b); i -= (d))
#define reps(i, s) for(i = 0; (s)[i]; ++i)
#define repl(i, l) for(i = l.begin(); i != l.end(); ++i)

#define in(f, a) scanf("%"#f, &(a))

bool firstout = 1;

#define out(f, a) printf("%"#f, (a))
#define outf(f, a) printf((firstout) ? "%"#f : " %"#f, (a)), firstout = 0
#define nl printf("\n"), firstout = 1

#define all(x) (x).begin(),(x).end()
#define sqr(x) ((x) * (x))
#define mp make_pair

template<class T>
T &minn(T &a, T b)
{
	if(b < a) a = b;
	return a;
}

template<class T>
T &maxx(T &a, T b)
{
	if(a < b) a = b;
	return a;
}

#define inf 1012345678
#define eps 1e-9

#ifdef XDEBUG
#define mod 23
#else
#define mod 1000000007
#endif

int &madd(int &a, int b)
{
	a += b;
	if(a >= mod) a -= mod;
	return a;
}

int &msub(int &a, int b)
{
	a -= b;
	if(a < 0) a += mod;
	return a;
}

int &mmult(int &a, int b)
{
	return a = (ll)a * b % mod;
}

int mdiv(ll a, ll b, ll m)
{
	a = (a % m + m) % m;
	b = (b % m + m) % m;
	if(a % b == 0) return a / b;
	return (a + m * mdiv(-a, m, b)) / b;
}

#define N 600123
#define M 1012

int n, m, q, nt;
int A[N], B[N];
int T[N], TT[N];
int L[N], R[N];
map<int, int> D;

void add(int i, int l, int r, int t)
{
	maxx(l, L[i]);
	minn(r, R[i]);
	if(l > r) return;
	if(l == L[i] && r == R[i])
	{
		T[i] += t;
		TT[i] += t;
		return;
	}
	if(TT[i])
	{
		T[2 * i] += TT[i];
		TT[2 * i] += TT[i];
		T[2 * i + 1] += TT[i];
		TT[2 * i + 1] += TT[i];
		TT[i] = 0;
	}
	add(2 * i, l, r, t);
	add(2 * i + 1, l, r, t);
	T[i] = max(T[2 * i], T[2 * i + 1]);
}

int main()
{
#ifdef XDEBUG
	freopen("in.txt", "rt", stdin);
#else
#endif

	int i, j, k;
	char c;
	int a, d;

	int ts;
#if 0
	int tss;
	in(d, tss);
	rep(ts, 1, tss + 1)
#else
	for(ts = 1; in(d, n) > 0; ++ts)
#endif
	{
		in(d, m); in(d, q);
		rep(i, 0, m) in(d, B[i]);
		rep(i, 0, n) in(d, A[i]);
		sort(B, B + m);
		repb(i, m, 0) D[B[i]] = i;
		nt = m;
		for(; nt & nt - 1; ++nt);
		rep(i, 0, nt) T[nt + i] = TT[nt + i] = 0, L[nt + i] = R[nt + i] = i;
		rep(i, 0, m) T[nt + i] = i - m;
		repb(i, nt, 0) T[i] = max(T[2 * i], T[2 * i + 1]), TT[i] = 0, L[i] = L[2 * i], R[i] = R[2 * i + 1];
		int g = 0, b = 0;
		map<int, int>::iterator mi;
		rep(i, 0, m - 1)
		{
			a = q - A[i];
			if(a <= 0) ++g;
			else
			{
				mi = D.lower_bound(a);
				if(mi == D.end()) ++b;
				else
				{
					add(1, 0, mi->second, 1);
				}
			}
		}
		int res = 0;
		rep(i, 0, n - m + 1)
		{
			a = q - A[i + m - 1];
			if(a <= 0) ++g;
			else
			{
				mi = D.lower_bound(a);
				if(mi == D.end()) ++b;
				else
				{
					add(1, 0, mi->second, 1);
				}
			}
			if(g || (b == 0 && T[1] <= 0)) ++res;
			a = q - A[i];
			if(a <= 0) --g;
			else
			{
				mi = D.lower_bound(a);
				if(mi == D.end()) --b;
				else
				{
					add(1, 0, mi->second, -1);
				}
			}
		}
		out(d, res); nl;
	}

	return 0;
}


#include <iostream>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>

using namespace std;

#define ll long long
#pragma comment(linker, "/STACK:64000000")

const int maxn = 1 << 18;
const int inf = 1000000007;
const int mod = 1000000007;

int n, len, h;
int a[maxn], b[maxn];

int t[2 * maxn], add[2 * maxn];

void push(int v, int tl, int tr) {
	if (add[v]) {
		if (tl != tr) add[v * 2] += add[v];
		if (tl != tr) add[v * 2 + 1] += add[v];
		t[v] += add[v];
		add[v] = 0;
	}
}

void upd(int v, int tl, int tr, int l, int r, int x) {
	push(v, tl, tr);
	if (l > r) return;
	if (l == tl && r == tr) {
		add[v] += x;
		push(v, tl, tr);
		return;
	}
	int tm = (tl + tr) >> 1;
	upd(v * 2, tl, tm, l, min(r, tm), x);
	upd(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, x);
	t[v] = min(t[v * 2], t[v * 2 + 1]);
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	while (cin >> n >> len >> h) {
		for (int i = 0; i < len; i++) cin >> b[i];
		for (int i = 0; i < n; i++) cin >> a[i];
		sort(b, b + len);

		for (int i = 0; i < len; i++) upd(1, 0, len - 1, i, i, -i - 1);
		for (int i = 0; i < len; i++) upd(1, 0, len - 1, lower_bound(b, b + len, h - a[i]) - b, len - 1, 1);

		int ans = 0;
		for (int i = 0; i + len - 1 < n; i++) {
			ans += t[1] >= 0;
			upd(1, 0, len - 1, lower_bound(b, b + len, h - a[i]) - b, len - 1, -1);
			upd(1, 0, len - 1, lower_bound(b, b + len, h - a[i + len]) - b, len - 1, 1);
		}
		cout << ans << endl;
	}

	return 0;
}


#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 <string.h>
#include <ctime>
#include <limits.h>
using namespace std;

typedef long long ll;
const double pi=acos(-1.0);
const double eps=1e-11;
//const ll INF=(_I64_MAX)/2;
#pragma comment(linker, "/STACK:102400000,102400000")
const int inf=0x3f3f3f3f;
#define maxx(a) memset(a, 0x3f, sizeof(a))
#define zero(a) memset(a, 0, sizeof(a))
template<class T>void show(T a, int n){for(int i=0; i<n; ++i) cout<<a[i]<<' '; cout<<endl;}
template<class T>void show(T a, int r, int l){for(int i=0; i<r; ++i)show(a[i],l);cout<<endl;}
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) for(i = n-1;i>=0;i--)
#define srep(i,n) for(i = 1;i <= n;i ++)
#define snuke(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define MP make_pair
typedef pair<int,int> PII;

const int N = 150000 * 4+ 111;
const ll mod = 1e9 + 9;

#define M ((l+r)>>1)
#define lc (o<<1)
#define rc (lc|1)
ll k[N],add[N];
int x,y,z;
void pushdown(int l,int r,int o)
{
     add[lc] += add[o];
     add[rc] += add[o];
     add[o] = 0;
}
void maintain(int l,int r,int o)
{
     int mid = M;
     if(r > l){
         k[o] = min(k[lc] + add[lc],k[rc] + add[rc]);
     }
}
void update(int l,int r,int o)
{
     if(x <= l && r <= y){
          add[o] += z;
          return;
     }
    pushdown(l,r,o);
    int mid = M;
    if(x <= mid) update(l,mid,lc);
    if(y > mid) update(mid + 1,r,rc);
    maintain(l,r,o);
}

int h;
int n,m;
int b[N];
int c[N];
void play(){
    scanf("%d%d%d",&m,&n,&h);
    int i,j;
    srep(i,n) {
        scanf("%d",b+i);
    }
    sort(b+1,b+n+1);
    srep(i,m){
        scanf("%d",&x);
        x = h - x;
        c[i] = lower_bound(b,b+n+1,x) - b + 1;
    }

    srep(i,n){
        x = y = i;
        z = i;
        update(1,n,1);
    }

    srep(i,n-1){
        x = c[i];
        if(!x) continue;
        y = n;
        z = -1;
        update(1,n,1);
    }

    int ans = 0;
    for(i = n;i <= m;i ++){
        x = c[i],y = n,z = -1;
        update(1,n,1);
        if(k[1] + add[1] == 0) ans++;
        x = c[i-n+1],y = n,z = 1;
        update(1,n,1);
    }

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

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

     play();

#ifndef ONLINE_JUDGE
     cerr << "time = " << clock() << " ms" << endl;
#endif

     return 0;
}


#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 <string.h>
#include <ctime>
#include <limits.h>
using namespace std;

typedef long long ll;
const double pi=acos(-1.0);
const double eps=1e-11;
//const ll INF=(_I64_MAX)/2;
#pragma comment(linker, "/STACK:102400000,102400000")
const int inf=0x3f3f3f3f;
#define maxx(a) memset(a, 0x3f, sizeof(a))
#define zero(a) memset(a, 0, sizeof(a))
template<class T>void show(T a, int n){for(int i=0; i<n; ++i) cout<<a[i]<<' '; cout<<endl;}
template<class T>void show(T a, int r, int l){for(int i=0; i<r; ++i)show(a[i],l);cout<<endl;}
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) for(i = n-1;i>=0;i--)
#define srep(i,n) for(i = 1;i <= n;i ++)
#define snuke(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define MP make_pair
typedef pair<int,int> PII;

const int N = 150000 * 4+ 111;
const ll mod = 1e9 + 9;

#define M ((l+r)>>1)
#define lc (o<<1)
#define rc (lc|1)
ll k[N],add[N];
int x,y,z;
void pushdown(int l,int r,int o)
{
     add[lc] += add[o];
     add[rc] += add[o];
     add[o] = 0;
}
void maintain(int l,int r,int o)
{
     int mid = M;
     if(r > l){
         k[o] = min(k[lc] + add[lc],k[rc] + add[rc]);
     }
}
void update(int l,int r,int o)
{
     if(x <= l && r <= y){
          add[o] += z;
          return;
     }
    pushdown(l,r,o);
    int mid = M;
    if(x <= mid) update(l,mid,lc);
    if(y > mid) update(mid + 1,r,rc);
    maintain(l,r,o);
}

int h;
int n,m;
int b[N];
int c[N];
void play(){
    scanf("%d%d%d",&m,&n,&h);
    int i,j;
    rep(i,n) {
        scanf("%d",b+i);
    }
    sort(b,b+n);
    srep(i,m){
        scanf("%d",&x);
        x = h - x;
        c[i] = lower_bound(b,b+n,x) - b;
    }

    rep(i,n){
        x = y = i;
        z = n - i;
        update(0,n,1);
    }

    srep(i,n-1){
        y = c[i];
        x = 0;
        z = -1;
        update(0,n,1);
    }

    int ans = 0;
    for(i = n;i <= m;i ++){
        y = c[i],x = 0,z = -1;
        update(0,n,1);
        if(k[1] + add[1] == 0) ans++;
        y = c[i-n+1],x = 0,z = 1;
        update(0,n,1);
    }

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

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

     play();

#ifndef ONLINE_JUDGE
     cerr << "time = " << clock() << " ms" << endl;
#endif

     return 0;
}#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 <string.h>
#include <ctime>
#include <limits.h>
using namespace std;

typedef long long ll;
const double pi=acos(-1.0);
const double eps=1e-11;
//const ll INF=(_I64_MAX)/2;
#pragma comment(linker, "/STACK:102400000,102400000")
const int inf=0x3f3f3f3f;
#define maxx(a) memset(a, 0x3f, sizeof(a))
#define zero(a) memset(a, 0, sizeof(a))
template<class T>void show(T a, int n){for(int i=0; i<n; ++i) cout<<a[i]<<' '; cout<<endl;}
template<class T>void show(T a, int r, int l){for(int i=0; i<r; ++i)show(a[i],l);cout<<endl;}
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) for(i = n-1;i>=0;i--)
#define srep(i,n) for(i = 1;i <= n;i ++)
#define snuke(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define MP make_pair
typedef pair<int,int> PII;

const int N = 150000 * 4+ 111;
const ll mod = 1e9 + 9;

#define M ((l+r)>>1)
#define lc (o<<1)
#define rc (lc|1)
ll k[N],add[N];
int x,y,z;
void pushdown(int l,int r,int o)
{
     add[lc] += add[o];
     add[rc] += add[o];
     add[o] = 0;
}
void maintain(int l,int r,int o)
{
     int mid = M;
     if(r > l){
         k[o] = min(k[lc] + add[lc],k[rc] + add[rc]);
     }
}
void update(int l,int r,int o)
{
     if(x <= l && r <= y){
          add[o] += z;
          return;
     }
    pushdown(l,r,o);
    int mid = M;
    if(x <= mid) update(l,mid,lc);
    if(y > mid) update(mid + 1,r,rc);
    maintain(l,r,o);
}

int h;
int n,m;
int b[N];
int c[N];
void play(){
    scanf("%d%d%d",&m,&n,&h);
    int i,j;
    srep(i,n) {
        scanf("%d",b+i);
    }
    sort(b+1,b+n+1);
    srep(i,m){
        scanf("%d",&x);
        x = h - x;
        c[i] = lower_bound(b,b+n+1,x) - b + 1;
    }

    srep(i,n){
        x = y = i;
        z = i;
        update(0,n,1);
    }

    srep(i,n-1){
        x = c[i];
        //if(!x) continue;
        y = n;
        z = -1;
        update(0,n,1);
    }

    int ans = 0;
    for(i = n;i <= m;i ++){
        x = c[i],y = n,z = -1;
        update(0,n,1);
        if(k[1] + add[1] == 0) ans++;
        x = c[i-n+1],y = n,z = 1;
        update(0,n,1);
    }

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

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

     play();

#ifndef ONLINE_JUDGE
     cerr << "time = " << clock() << " ms" << endl;
#endif

     return 0;
}


#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 <string.h>
#include <ctime>
#include <limits.h>
using namespace std;

typedef long long ll;
const double pi=acos(-1.0);
const double eps=1e-11;
//const ll INF=(_I64_MAX)/2;
#pragma comment(linker, "/STACK:102400000,102400000")
const int inf=0x3f3f3f3f;
#define maxx(a) memset(a, 0x3f, sizeof(a))
#define zero(a) memset(a, 0, sizeof(a))
template<class T>void show(T a, int n){for(int i=0; i<n; ++i) cout<<a[i]<<' '; cout<<endl;}
template<class T>void show(T a, int r, int l){for(int i=0; i<r; ++i)show(a[i],l);cout<<endl;}
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) for(i = n-1;i>=0;i--)
#define srep(i,n) for(i = 1;i <= n;i ++)
#define snuke(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define MP make_pair
typedef pair<int,int> PII;

const int N = 150000 * 4+ 111;
const ll mod = 1e9 + 9;

#define M ((l+r)>>1)
#define lc (o<<1)
#define rc (lc|1)
ll k[N],add[N];
int x,y,z;
void pushdown(int l,int r,int o)
{
     add[lc] += add[o];
     add[rc] += add[o];
     add[o] = 0;
}
void maintain(int l,int r,int o)
{
     int mid = M;
     if(r > l){
         k[o] = min(k[lc] + add[lc],k[rc] + add[rc]);
     }
}
void update(int l,int r,int o)
{
     if(x <= l && r <= y){
          add[o] += z;
          return;
     }
    pushdown(l,r,o);
    int mid = M;
    if(x <= mid) update(l,mid,lc);
    if(y > mid) update(mid + 1,r,rc);
    maintain(l,r,o);
}

int h;
int n,m;
int b[N];
int c[N];
void play(){
    scanf("%d%d%d",&m,&n,&h);
    int i,j;
    rep(i,n) {
        scanf("%d",b+i);
    }
    sort(b,b+n);
    srep(i,m){
        scanf("%d",&x);
        x = h - x;
        c[i] = lower_bound(b,b+n,x) - b;
    }

    rep(i,n){
        x = y = i;
        z = n - i;
        update(0,n,1);
    }

    srep(i,n-1){
        y = c[i];
        x = 0;
        z = -1;
        update(0,n,1);
    }

    int ans = 0;
    for(i = n;i <= m;i ++){
        y = c[i],x = 0,z = -1;
        update(0,n,1);
        if(k[1] + add[1] == 0) ans++;
        y = c[i-n+1],x = 0,z = 1;
        update(0,n,1);
    }

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

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

     play();

#ifndef ONLINE_JUDGE
     cerr << "time = " << clock() << " ms" << endl;
#endif

     return 0;
}


#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 <string.h>
#include <ctime>
#include <limits.h>
using namespace std;

typedef long long ll;
const double pi=acos(-1.0);
const double eps=1e-11;
//const ll INF=(_I64_MAX)/2;
#pragma comment(linker, "/STACK:102400000,102400000")
const int inf=0x3f3f3f3f;
#define maxx(a) memset(a, 0x3f, sizeof(a))
#define zero(a) memset(a, 0, sizeof(a))
template<class T>void show(T a, int n){for(int i=0; i<n; ++i) cout<<a[i]<<' '; cout<<endl;}
template<class T>void show(T a, int r, int l){for(int i=0; i<r; ++i)show(a[i],l);cout<<endl;}
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) for(i = n-1;i>=0;i--)
#define srep(i,n) for(i = 1;i <= n;i ++)
#define snuke(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define MP make_pair
typedef pair<int,int> PII;

const int N = 150000 * 4+ 111;
const ll mod = 1e9 + 9;

#define M ((l+r)>>1)
#define lc (o<<1)
#define rc (lc|1)
ll k[N],add[N];
int x,y,z;
void pushdown(int l,int r,int o)
{
     add[lc] += add[o];
     add[rc] += add[o];
     add[o] = 0;
}
void maintain(int l,int r,int o)
{
     int mid = M;
     if(r > l){
         k[o] = min(k[lc] + add[lc],k[rc] + add[rc]);
     }
}
void update(int l,int r,int o)
{
     if(x <= l && r <= y){
          add[o] += z;
          return;
     }
    pushdown(l,r,o);
    int mid = M;
    if(x <= mid) update(l,mid,lc);
    if(y > mid) update(mid + 1,r,rc);
    maintain(l,r,o);
}

int h;
int n,m;
int b[N];
int c[N];
void play(){
    scanf("%d%d%d",&m,&n,&h);
    int i,j;
    srep(i,n) {
        scanf("%d",b+i);
    }
    sort(b+1,b+n+1);
    srep(i,m){
        scanf("%d",&x);
        x = h - x;
        c[i] = lower_bound(b,b+n+1,x) - b + 1;
    }

    srep(i,n){
        x = y = i;
        z = i;
        update(0,n,1);
    }

    srep(i,n-1){
        x = c[i];
        //if(!x) continue;
        y = n;
        z = -1;
        update(0,n,1);
    }

    int ans = 0;
    for(i = n;i <= m;i ++){
        x = c[i],y = n,z = -1;
        update(0,n,1);
        if(k[1] + add[1] == 0) ans++;
        x = c[i-n+1],y = n,z = 1;
        update(0,n,1);
    }

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

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

     play();

#ifndef ONLINE_JUDGE
     cerr << "time = " << clock() << " ms" << endl;
#endif

     return 0;
}


#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 <string.h>
#include <ctime>
#include <limits.h>
using namespace std;

typedef long long ll;
const double pi=acos(-1.0);
const double eps=1e-11;
//const ll INF=(_I64_MAX)/2;
#pragma comment(linker, "/STACK:102400000,102400000")
const int inf=0x3f3f3f3f;
#define maxx(a) memset(a, 0x3f, sizeof(a))
#define zero(a) memset(a, 0, sizeof(a))
template<class T>void show(T a, int n){for(int i=0; i<n; ++i) cout<<a[i]<<' '; cout<<endl;}
template<class T>void show(T a, int r, int l){for(int i=0; i<r; ++i)show(a[i],l);cout<<endl;}
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) for(i = n-1;i>=0;i--)
#define srep(i,n) for(i = 1;i <= n;i ++)
#define snuke(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define MP make_pair
typedef pair<int,int> PII;

const int N = 150000 * 4+ 111;
const ll mod = 1e9 + 9;

#define M ((l+r)>>1)
#define lc (o<<1)
#define rc (lc|1)
ll k[N],add[N];
int x,y,z;
void pushdown(int l,int r,int o)
{
     add[lc] += add[o];
     add[rc] += add[o];
     add[o] = 0;
}
void maintain(int l,int r,int o)
{
     int mid = M;
     if(r > l){
         k[o] = min(k[lc] + add[lc],k[rc] + add[rc]);
     }
}
void update(int l,int r,int o)
{
     if(x <= l && r <= y){
          add[o] += z;
          return;
     }
    pushdown(l,r,o);
    int mid = M;
    if(x <= mid) update(l,mid,lc);
    if(y > mid) update(mid + 1,r,rc);
    maintain(l,r,o);
}

int h;
int n,m;
int b[N];
int c[N];
void play(){
    scanf("%d%d%d",&m,&n,&h);
    int i,j;
    rep(i,n) {
        scanf("%d",b+i);
    }
    sort(b,b+n);
    srep(i,m){
        scanf("%d",&x);
        x = h - x;
        c[i] = lower_bound(b,b+n,x) - b;
    }

    rep(i,n){
        x = y = i;
        z = n - i;
        update(0,n,1);
    }

    srep(i,n-1){
        y = c[i];
        x = 0;
        z = -1;
        update(0,n,1);
    }

    int ans = 0;
    for(i = n;i <= m;i ++){
        y = c[i],x = 0,z = -1;
        update(0,n,1);
        if(k[1] + add[1] >= 0) ans++;
        y = c[i-n+1],x = 0,z = 1;
        update(0,n,1);
    }

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

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

     play();

#ifndef ONLINE_JUDGE
     cerr << "time = " << clock() << " ms" << endl;
#endif

     return 0;
}


#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <queue>
#include<set>
#include<stack>
#include<cstdio>
#include <unordered_map>
#include <functional>
#define PI 3.14159265
using namespace std;

#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
const int maxn = 150010;
int seg[maxn << 2];
int mrk[maxn << 2];
int a[maxn];
int b[maxn];
int n, len, h;

void PushUP(int rt) {
	seg[rt] = min(seg[rt << 1],seg[rt << 1 | 1]);
}
void build(int l, int r, int rt) {
	if (l == r) {
		mrk[rt] = 0;
		seg[rt] = l - len-1;
		return;
	}
	mrk[rt] = 0;
	int m = (l + r) >> 1;
	build(lson);
	build(rson);
	PushUP(rt);
}
void PushDown(int rt) {
	if (mrk[rt]) {
		mrk[rt << 1] = mrk[rt << 1 | 1] = mrk[rt];
		seg[rt << 1] += mrk[rt];
		seg[rt << 1 | 1] += mrk[rt];
		mrk[rt] = 0;
	}
}

void update(int L, int R, int c, int l, int r, int rt) {
	if (L <= l && r <= R) {
		mrk[rt] += c;
		seg[rt] +=c;
		return;
	}
	PushDown(rt);
	int m = (l + r) >> 1;
	if (L <= m) update(L, R, c, lson);
	if (R > m) update(L, R, c, rson);
	PushUP(rt);
}

int query(int L, int R, int l, int r, int rt) {
	if (L <= l && r <= R) {
		return seg[rt];
	}
	PushDown(rt);
	int m = (l + r) >> 1;
	int ret = 1000000002;
	if (L <= m) ret = min(ret,query(L, R, lson));
	if (m < R) ret = min(ret,query(L, R, rson));
	return ret;
}

int naive(int ind){
	int c[6];
	for (int i = 0; i < 6; i++) c[i] = a[i + ind];
	sort(c, c + 6);
	for (int i = 0; i < 6; i++) if (c[i] < b[i]) return 0;
	return 1;
}
int main(){
	std::ios_base::sync_with_stdio(false);

	cin >> n >> len >> h;
	for (int i = 0; i < len; i++){
		int a;
		cin >> a;
		b[i] = h - a;
	}
	sort(b, b + len);
	int m = len;
	build(1, m, 1);
	int ans = 0;
	for (int i = 0; i < n; i++){
		cin >> a[i];
		int order = upper_bound(b, b + len, a[i]) - b;
		if(order>0)update(1, order, 1, 1, m, 1);
		//cout << seg[1] << endl;
		if (i >= len - 1){
			if (seg[1]<0 && naive(i - len + 1) && len == 6) cout << "different at " << i << endl;
			if (seg[1] >= 0) ans++;
			order = upper_bound(b, b + len, a[i-len+1]) - b;
			if (order>0)update(1, order, -1, 1, m, 1);
		}

	}
	cout << ans << endl;
	//system("PAUSE");
	return 0;
}


#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <queue>
#include<set>
#include<stack>
#include<cstdio>
#include <unordered_map>
#include <functional>
#define PI 3.14159265
using namespace std;

#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
const int maxn = 150010;
int seg[maxn << 2];
int mrk[maxn << 2];
int a[maxn];
int b[maxn];
int n, len, h;

void PushUP(int rt) {
	seg[rt] = min(seg[rt << 1],seg[rt << 1 | 1]);
}
void build(int l, int r, int rt) {
	if (l == r) {
		mrk[rt] = 0;
		seg[rt] = l - len-1;
		return;
	}
	mrk[rt] = 0;
	int m = (l + r) >> 1;
	build(lson);
	build(rson);
	PushUP(rt);
}
void PushDown(int rt) {
	if (mrk[rt]) {
		mrk[rt << 1] = mrk[rt << 1 | 1] = mrk[rt];
		seg[rt << 1] += mrk[rt];
		seg[rt << 1 | 1] += mrk[rt];
		mrk[rt] = 0;
	}
}

void update(int L, int R, int c, int l, int r, int rt) {
	if (L <= l && r <= R) {
		mrk[rt] += c;
		seg[rt] +=c;
		return;
	}
	PushDown(rt);
	int m = (l + r) >> 1;
	if (L <= m) update(L, R, c, lson);
	if (R > m) update(L, R, c, rson);
	PushUP(rt);
}

int query(int L, int R, int l, int r, int rt) {
	if (L <= l && r <= R) {
		return seg[rt];
	}
	PushDown(rt);
	int m = (l + r) >> 1;
	int ret = 1000000002;
	if (L <= m) ret = min(ret,query(L, R, lson));
	if (m < R) ret = min(ret,query(L, R, rson));
	return ret;
}

int naive(int ind){
	int c[6];
	for (int i = 0; i < 6; i++) c[i] = a[i + ind];
	sort(c, c + 6);
	for (int i = 0; i < 6; i++) if (c[i] < b[i]) return 0;
	return 1;
}
int main(){
	std::ios_base::sync_with_stdio(false);

	cin >> n >> len >> h;
	for (int i = 0; i < len; i++){
		int a;
		cin >> a;
		b[i] = h - a;
	}
	sort(b, b + len);
	int m = len;
	build(1, m, 1);
	int ans = 0;
	for (int i = 0; i < n; i++){
		cin >> a[i];
		int order = upper_bound(b, b + len, a[i]) - b;
		if(order>0)update(1, order, 1, 1, m, 1);
		//cout << seg[1] << endl;
		if (i >= len - 1){
			if (seg[1]<0 && naive(i - len + 1) && len == 6) {
				cout << "different at " << i<<"seg is "<<seg[1]<<", a=";
				for (int j = i - len + 1; j <= i; j++) cout << a[j] << " ";
				cout << "while b=";
				for (int j = i - len + 1; j <= i; j++) cout << b[j] << " ";
				cout<<endl;
			}
			if (seg[1] >= 0) ans++;
			order = upper_bound(b, b + len, a[i-len+1]) - b;
			if (order>0)update(1, order, -1, 1, m, 1);
		}

	}
	cout << ans << endl;
	//system("PAUSE");
	return 0;
}


#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <queue>
#include<set>
#include<stack>
#include<cstdio>
#include <unordered_map>
#include <functional>
#define PI 3.14159265
using namespace std;

#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
const int maxn = 150010;
int seg[maxn << 2];
int mrk[maxn << 2];
int a[maxn];
int b[maxn];
int n, len, h;

void PushUP(int rt) {
	seg[rt] = min(seg[rt << 1],seg[rt << 1 | 1]);
}
void build(int l, int r, int rt) {
	if (l == r) {
		mrk[rt] = 0;
		seg[rt] = l - len-1;
		return;
	}
	mrk[rt] = 0;
	int m = (l + r) >> 1;
	build(lson);
	build(rson);
	PushUP(rt);
}
void PushDown(int rt) {
	if (mrk[rt]!=0) {
		mrk[rt << 1] += mrk[rt];
		mrk[rt << 1 | 1] += mrk[rt];
		seg[rt << 1] += mrk[rt];
		seg[rt << 1 | 1] += mrk[rt];
		mrk[rt] = 0;
	}
}

void update(int L, int R, int c, int l, int r, int rt) {
	if (L <= l && r <= R) {
		mrk[rt] += c;
		seg[rt] += c;
		return;
	}
	PushDown(rt);
	int m = (l + r) >> 1;
	if (L <= m) update(L, R, c, lson);
	if (R > m) update(L, R, c, rson);
	PushUP(rt);
}

/*int query(int L, int R, int l, int r, int rt) {
	if (L <= l && r <= R) {
		return seg[rt];
	}
	PushDown(rt);
	int m = (l + r) >> 1;
	int ret = 1000000002;
	if (L <= m) ret = min(ret,query(L, R, lson));
	if (m < R) ret = min(ret,query(L, R, rson));
	return ret;
}

int naive(int ind){
	int c[6];
	for (int i = 0; i < 6; i++) c[i] = a[i + ind];
	sort(c, c + 6);
	for (int i = 0; i < 6; i++) if (c[i] < b[i]) return 0;
	return 1;
}*/
int main(){
	std::ios_base::sync_with_stdio(false);

	cin >> n >> len >> h;
	for (int i = 0; i < len; i++){
		int a;
		cin >> a;
		b[i] = h - a;
	}
	sort(b, b + len);
	int m = len;
	build(1, m, 1);
	int ans = 0;
	for (int i = 0; i < n; i++){
		cin >> a[i];
		int order = upper_bound(b, b + len, a[i]) - b;
		if(order>0)update(1, order, 1, 1, m, 1);

		if (i >= len - 1){
			if (seg[1] >= 0) ans++;
			order = upper_bound(b, b + len, a[i-len+1]) - b;
			if (order>0)update(1, order, -1, 1, m, 1);

		}

	}
	cout << ans << endl;
	system("PAUSE");
	return 0;
}


#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <queue>
#include<set>
#include<stack>
#include<cstdio>
#include <unordered_map>
#include <functional>
#define PI 3.14159265
using namespace std;

#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
const int maxn = 150010;
int seg[maxn << 2];
int mrk[maxn << 2];
int a[maxn];
int b[maxn];
int n, len, h;

void PushUP(int rt) {
	seg[rt] = min(seg[rt << 1],seg[rt << 1 | 1]);
}
void build(int l, int r, int rt) {
	if (l == r) {
		mrk[rt] = 0;
		seg[rt] = l - len-1;
		return;
	}
	mrk[rt] = 0;
	int m = (l + r) >> 1;
	build(lson);
	build(rson);
	PushUP(rt);
}
void PushDown(int rt) {
	if (mrk[rt]) {
		mrk[rt << 1] = mrk[rt << 1 | 1] = mrk[rt];
		seg[rt << 1] += mrk[rt];
		seg[rt << 1 | 1] += mrk[rt];
		mrk[rt] = 0;
	}
}

void update(int L, int R, int c, int l, int r, int rt) {
	if (L <= l && r <= R) {
		mrk[rt] += c;
		seg[rt] +=c;
		return;
	}
	PushDown(rt);
	int m = (l + r) >> 1;
	if (L <= m) update(L, R, c, lson);
	if (R > m) update(L, R, c, rson);
	PushUP(rt);
}

int query(int L, int R, int l, int r, int rt) {
	if (L <= l && r <= R) {
		return seg[rt];
	}
	PushDown(rt);
	int m = (l + r) >> 1;
	int ret = 1000000002;
	if (L <= m) ret = min(ret,query(L, R, lson));
	if (m < R) ret = min(ret,query(L, R, rson));
	return ret;
}

int naive(int ind){
	int c[6];
	for (int i = 0; i < 6; i++) c[i] = a[i + ind];
	sort(c, c + 6);
	for (int i = 0; i < 6; i++) if (c[i] < b[i]) return 0;
	return 1;
}
int main(){
	std::ios_base::sync_with_stdio(false);

	cin >> n >> len >> h;
	for (int i = 0; i < len; i++){
		int a;
		cin >> a;
		b[i] = h - a;
	}
	sort(b, b + len);
	int m = len;
	build(1, m, 1);
	int ans = 0;
	for (int i = 0; i < n; i++){
		cin >> a[i];
		int order = upper_bound(b, b + len, a[i]) - b;
		if(order>0)update(1, order, 1, 1, m, 1);
		if(i<=69 && i>=66) cout<<"insert="<<order<<endl;
		//cout << seg[1] << endl;
		if (i >= len - 1){
			/*if (seg[1]<0 && naive(i - len + 1) && len == 6) {
				cout << "different at " << i<<"seg is "<<seg[1]<<", a=";
				for (int j = i - len + 1; j <= i; j++) cout << a[j] << " ";
				cout << "while b=";
				for (int j = 0; j < len; j++) cout << b[j] << " ";
				cout<<endl;
			}*/
			if (seg[1] >= 0) ans++;
			order = upper_bound(b, b + len, a[i-len+1]) - b;
			if(i<=69 && i>=66) cout<<"delete="<<order<<endl;
			if (order>0)update(1, order, -1, 1, m, 1);
		}

	}
	cout << ans << endl;
//	system("PAUSE");
	return 0;
}


#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <queue>
#include<set>
#include<stack>
#include<cstdio>
#include <unordered_map>
#include <functional>
#define PI 3.14159265
using namespace std;

#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
const int maxn = 150010;
int seg[maxn << 2];
int mrk[maxn << 2];
int a[maxn];
int b[maxn];
int n, len, h;

void PushUP(int rt) {
	seg[rt] = min(seg[rt << 1],seg[rt << 1 | 1]);
}
void build(int l, int r, int rt) {
	if (l == r) {
		mrk[rt] = 0;
		seg[rt] = l - len-1;
		return;
	}
	mrk[rt] = 0;
	int m = (l + r) >> 1;
	build(lson);
	build(rson);
	PushUP(rt);
}
void PushDown(int rt) {
	if (mrk[rt]) {
		mrk[rt << 1] = mrk[rt << 1 | 1] = mrk[rt];
		seg[rt << 1] += mrk[rt];
		seg[rt << 1 | 1] += mrk[rt];
		mrk[rt] = 0;
	}
}

void update(int L, int R, int c, int l, int r, int rt) {
	if (L <= l && r <= R) {
		mrk[rt] += c;
		seg[rt] +=c;
		return;
	}
	PushDown(rt);
	int m = (l + r) >> 1;
	if (L <= m) update(L, R, c, lson);
	if (R > m) update(L, R, c, rson);
	PushUP(rt);
}

int query(int L, int R, int l, int r, int rt) {
	if (L <= l && r <= R) {
		return seg[rt];
	}
	PushDown(rt);
	int m = (l + r) >> 1;
	int ret = 1000000002;
	if (L <= m) ret = min(ret,query(L, R, lson));
	if (m < R) ret = min(ret,query(L, R, rson));
	return ret;
}
int main(){
	std::ios_base::sync_with_stdio(false);

	cin >> n >> len >> h;
	for (int i = 0; i < len; i++){
		int a;
		cin >> a;
		b[i] = h - a;
	}
	sort(b, b + len);
	int m = len;
	build(1, m, 1);
	int ans = 0;
	for (int i = 0; i < n; i++){
		cin >> a[i];
		int order = upper_bound(b, b + len, a[i]) - b;
		if(order>0)update(1, order, 1, 1, m, 1);
		//cout << seg[1] << endl;
		if (i >= len - 1){
			if (seg[1] >= 0) ans++;
			order = upper_bound(b, b + len, a[i-len+1]) - b;
			if (order>0)update(1, order, -1, 1, m, 1);
		}

	}
	cout << ans << endl;
//	system("PAUSE");
	return 0;
}


#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <queue>
#include<set>
#include<stack>
#include<cstdio>
#include <unordered_map>
#include <functional>
#define PI 3.14159265
using namespace std;

#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
const int maxn = 150010;
int seg[maxn << 2];
int mrk[maxn << 2];
int a[maxn];
int b[maxn];
int n, len, h;

void PushUP(int rt) {
	seg[rt] = min(seg[rt << 1],seg[rt << 1 | 1]);
}
void build(int l, int r, int rt) {
	if (l == r) {
		mrk[rt] = 0;
		seg[rt] = l - len-1;
		return;
	}
	mrk[rt] = 0;
	int m = (l + r) >> 1;
	build(lson);
	build(rson);
	PushUP(rt);
}
void PushDown(int rt) {
	if (mrk[rt]!=0) {
		mrk[rt << 1] += mrk[rt];
		mrk[rt << 1 | 1] += mrk[rt];
		seg[rt << 1] += mrk[rt];
		seg[rt << 1 | 1] += mrk[rt];
		mrk[rt] = 0;
	}
}

void update(int L, int R, int c, int l, int r, int rt) {
	if (L <= l && r <= R) {
		mrk[rt] += c;
		seg[rt] += c;
		return;
	}
	PushDown(rt);
	int m = (l + r) >> 1;
	if (L <= m) update(L, R, c, lson);
	if (R > m) update(L, R, c, rson);
	PushUP(rt);
}

/*int query(int L, int R, int l, int r, int rt) {
	if (L <= l && r <= R) {
		return seg[rt];
	}
	PushDown(rt);
	int m = (l + r) >> 1;
	int ret = 1000000002;
	if (L <= m) ret = min(ret,query(L, R, lson));
	if (m < R) ret = min(ret,query(L, R, rson));
	return ret;
}

int naive(int ind){
	int c[6];
	for (int i = 0; i < 6; i++) c[i] = a[i + ind];
	sort(c, c + 6);
	for (int i = 0; i < 6; i++) if (c[i] < b[i]) return 0;
	return 1;
}*/
int main(){
	std::ios_base::sync_with_stdio(false);

	cin >> n >> len >> h;
	for (int i = 0; i < len; i++){
		int a;
		cin >> a;
		b[i] = h - a;
	}
	sort(b, b + len);
	int m = len;
	build(1, m, 1);
	int ans = 0;
	for (int i = 0; i < n; i++){
		cin >> a[i];
		int order = upper_bound(b, b + len, a[i]) - b;
		if(order>0)update(1, order, 1, 1, m, 1);

		if (i >= len - 1){
			if (seg[1] >= 0) ans++;
			order = upper_bound(b, b + len, a[i-len+1]) - b;
			if (order>0)update(1, order, -1, 1, m, 1);

		}

	}
	cout << ans << endl;
	//system("PAUSE");
	return 0;
}


#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <queue>
#include<set>
#include<stack>
#include<cstdio>
#include <unordered_map>
#include <functional>
#define PI 3.14159265
using namespace std;

#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
const int maxn = 150010;
int seg[maxn << 2];
int mrk[maxn << 2];
int a[maxn];
int b[maxn];
int n, len, h;

void PushUP(int rt) {
	seg[rt] = min(seg[rt << 1],seg[rt << 1 | 1]);
}
void build(int l, int r, int rt) {
	if (l == r) {
		mrk[rt] = 0;
		seg[rt] = l - len-1;
		return;
	}
	mrk[rt] = 0;
	int m = (l + r) >> 1;
	build(lson);
	build(rson);
	PushUP(rt);
}
void PushDown(int rt) {
	if (mrk[rt]) {
		mrk[rt << 1] = mrk[rt << 1 | 1] = mrk[rt];
		seg[rt << 1] += mrk[rt];
		seg[rt << 1 | 1] += mrk[rt];
		mrk[rt] = 0;
	}
}

void update(int L, int R, int c, int l, int r, int rt) {
	if (L <= l && r <= R) {
		mrk[rt] += c;
		seg[rt] +=c;
		return;
	}
	PushDown(rt);
	int m = (l + r) >> 1;
	if (L <= m) update(L, R, c, lson);
	if (R > m) update(L, R, c, rson);
	PushUP(rt);
}

int query(int L, int R, int l, int r, int rt) {
	if (L <= l && r <= R) {
		return seg[rt];
	}
	PushDown(rt);
	int m = (l + r) >> 1;
	int ret = 1000000002;
	if (L <= m) ret = min(ret,query(L, R, lson));
	if (m < R) ret = min(ret,query(L, R, rson));
	return ret;
}

int naive(int ind){
	int c[6];
	for (int i = 0; i < 6; i++) c[i] = a[i + ind];
	sort(c, c + 6);
	for (int i = 0; i < 6; i++) if (c[i] < b[i]) return 0;
	return 1;
}
int main(){
	std::ios_base::sync_with_stdio(false);

	cin >> n >> len >> h;
	for (int i = 0; i < len; i++){
		int a;
		cin >> a;
		b[i] = h - a;
	}
	sort(b, b + len);
	int m = len;
	build(1, m, 1);
	int ans = 0;
	for (int i = 0; i < n; i++){
		cin >> a[i];
		int order = upper_bound(b, b + len, a[i]) - b;
		if(order>0)update(1, order, 1, 1, m, 1);
		//cout << seg[1] << endl;
		if (i >= len - 1){
			if (seg[1]<0 && naive(i - len + 1) && len == 6) {
				cout << "different at " << i<<"seg is "<<seg[1]<<", a=";
				for (int j = i - len + 1; j <= j; j++) cout << a[j] << " ";
				cout << "while b=";
				for (int j = i - len + 1; j <= j; j++) cout << b[j] << " ";
			}
			if (seg[1] >= 0) ans++;
			order = upper_bound(b, b + len, a[i-len+1]) - b;
			if (order>0)update(1, order, -1, 1, m, 1);
		}

	}
	cout << ans << endl;
	//system("PAUSE");
	return 0;
}


#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <queue>
#include<set>
#include<stack>
#include<cstdio>
#include <unordered_map>
#include <functional>
#define PI 3.14159265
using namespace std;

#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
const int maxn = 150010;
int seg[maxn << 2];
int mrk[maxn << 2];
int a[maxn];
int b[maxn];
int n, len, h;

void PushUP(int rt) {
	seg[rt] = min(seg[rt << 1],seg[rt << 1 | 1]);
}
void build(int l, int r, int rt) {
	if (l == r) {
		mrk[rt] = 0;
		seg[rt] = l - len-1;
		return;
	}
	mrk[rt] = 0;
	int m = (l + r) >> 1;
	build(lson);
	build(rson);
	PushUP(rt);
}
void PushDown(int rt) {
	if (mrk[rt]) {
		mrk[rt << 1] = mrk[rt << 1 | 1] = mrk[rt];
		seg[rt << 1] += mrk[rt];
		seg[rt << 1 | 1] += mrk[rt];
		mrk[rt] = 0;
	}
}

void update(int L, int R, int c, int l, int r, int rt) {
	if (L <= l && r <= R) {
		mrk[rt] += c;
		seg[rt] +=c;
		return;
	}
	PushDown(rt);
	int m = (l + r) >> 1;
	if (L <= m) update(L, R, c, lson);
	if (R > m) update(L, R, c, rson);
	PushUP(rt);
}

int query(int L, int R, int l, int r, int rt) {
	if (L <= l && r <= R) {
		return seg[rt];
	}
	PushDown(rt);
	int m = (l + r) >> 1;
	int ret = 1000000002;
	if (L <= m) ret = min(ret,query(L, R, lson));
	if (m < R) ret = min(ret,query(L, R, rson));
	return ret;
}

int naive(int ind){
	int c[6];
	for (int i = 0; i < 6; i++) c[i] = a[i + ind];
	sort(c, c + 6);
	for (int i = 0; i < 6; i++) if (c[i] < b[i]) return 0;
	return 1;
}
int main(){
	std::ios_base::sync_with_stdio(false);

	cin >> n >> len >> h;
	for (int i = 0; i < len; i++){
		int a;
		cin >> a;
		b[i] = h - a;
	}
	sort(b, b + len);
	int m = len;
	build(1, m, 1);
	int ans = 0;
	for (int i = 0; i < n; i++){
		cin >> a[i];
		int order = upper_bound(b, b + len, a[i]) - b;
		if(order>0)update(1, order, 1, 1, m, 1);
		//cout << seg[1] << endl;
		if (i >= len - 1){
			if (seg[1]<0 && naive(i - len + 1) && len == 6) {
				cout << "different at " << i<<"seg is "<<seg[1]<<", a=";
				for (int j = i - len + 1; j <= i; j++) cout << a[j] << " ";
				cout << "while b=";
				for (int j = 0; j < len; j++) cout << b[j] << " ";
				cout<<endl;
			}
			if (seg[1] >= 0) ans++;
			order = upper_bound(b, b + len, a[i-len+1]) - b;
			if (order>0)update(1, order, -1, 1, m, 1);
		}

	}
	cout << ans << endl;
//	system("PAUSE");
	return 0;
}


#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <queue>
#include<set>
#include<stack>
#include<cstdio>
#include <unordered_map>
#include <functional>
#define PI 3.14159265
using namespace std;

#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
const int maxn = 150010;
int seg[maxn << 2];
int mrk[maxn << 2];
int a[maxn];
int b[maxn];
int n, len, h;

void PushUP(int rt) {
	seg[rt] = min(seg[rt << 1],seg[rt << 1 | 1]);
}
void build(int l, int r, int rt) {
	if (l == r) {
		mrk[rt] = 0;
		seg[rt] = l - len-1;
		return;
	}
	mrk[rt] = 0;
	int m = (l + r) >> 1;
	build(lson);
	build(rson);
	PushUP(rt);
}
void PushDown(int rt) {
	if (mrk[rt]) {
		mrk[rt << 1] = mrk[rt << 1 | 1] = mrk[rt];
		seg[rt << 1] += mrk[rt];
		seg[rt << 1 | 1] += mrk[rt];
		mrk[rt] = 0;
	}
}

void update(int L, int R, int c, int l, int r, int rt) {
	if (L <= l && r <= R) {
		mrk[rt] += c;
		seg[rt] +=c;
		return;
	}
	PushDown(rt);
	int m = (l + r) >> 1;
	if (L <= m) update(L, R, c, lson);
	if (R > m) update(L, R, c, rson);
	PushUP(rt);
}

int query(int L, int R, int l, int r, int rt) {
	if (L <= l && r <= R) {
		return seg[rt];
	}
	PushDown(rt);
	int m = (l + r) >> 1;
	int ret = 1000000002;
	if (L <= m) ret = min(ret,query(L, R, lson));
	if (m < R) ret = min(ret,query(L, R, rson));
	return ret;
}

int naive(int ind){
	int c[6];
	for (int i = 0; i < 6; i++) c[i] = a[i + ind];
	sort(c, c + 6);
	for (int i = 0; i < 6; i++) if (c[i] < b[i]) return 0;
	return 1;
}
int main(){
	std::ios_base::sync_with_stdio(false);

	cin >> n >> len >> h;
	for (int i = 0; i < len; i++){
		int a;
		cin >> a;
		b[i] = h - a;
	}
	sort(b, b + len);
	int m = len;
	build(1, m, 1);
	int ans = 0;
	for (int i = 0; i < n; i++){
		cin >> a[i];
		int order = upper_bound(b, b + len, a[i]) - b;
		if(order>0)update(1, order, 1, 1, m, 1);
		//cout << seg[1] << endl;
		if (i >= len - 1){
			if (seg[1]<0 && naive(i - len + 1) && len == 6) {
				cout << "different at " << i<<"seg is "<<seg[1]<<", a=";
				for (int j = i - len + 1; j <= i; j++) cout << a[j] << " ";
				cout << "while b=";
				for (int j = 0; j < len; j++) cout << b[j] << " ";
			}
			if (seg[1] >= 0) ans++;
			order = upper_bound(b, b + len, a[i-len+1]) - b;
			if (order>0)update(1, order, -1, 1, m, 1);
		}

	}
	cout << ans << endl;
//	system("PAUSE");
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <algorithm>
#include <queue>
#include <functional>
#include <sstream>
#include <ctime>
#define lol long long
using namespace std;

struct Node
{
    int v, add;
    Node(int x) : v(x), add(0){};
    Node(){};
};

int len;
Node t[2 * 262144];

void build(int ind, int l, int r)
{
    if (l != r)
    {
        int m = (l + r) / 2;
        build(2 * ind, l, m);
        build(2 * ind + 1, m + 1, r);
        t[ind] = min(t[2 * ind].v, t[2 * ind + 1].v);
    }
    else
        t[ind] = Node(l < len ? -l : 228);
}

void upd(int ind, int tl, int tr, int l, int r, int add)
{
    if (l > r)
        return;
    if (tl == l && tr == r)
    {
        t[ind].add += add;
    }
    else
    {
        if (t[ind].add)
        {
            t[2 * ind].add += t[ind].add;
            t[2 * ind + 1].add += t[ind].add;
            t[ind].v += t[ind].add;
            t[ind].add = 0;
        }
        int m = (tl + tr) / 2;
        upd(2 * ind, tl, m, l, min(r, m), add);
        upd(2 * ind + 1, m + 1, r, max(l, m + 1), r, add);
        t[ind] = min(t[2 * ind].v + t[2 * ind].add, t[2 * ind + 1].v + t[2 * ind + 1].add);
    }
}

int SZ = 262144;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, h;
    cin >> n >> len >> h;
    vector<int> b(len);
    for (int i = 0; i < len; ++i)
        cin >> b[i];
    sort(b.begin(), b.end());

    vector<int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];

    build(1, 0, SZ - 1);

    for (int i = 0; i < len; ++i)
    {
        int ind = lower_bound(b.begin(), b.end(), h - a[i]) - b.begin();
        upd(1, 0, SZ - 1, ind, len - 1, 1);
    }

    int ans = 0;
    for (int i = len - 1; i < n; ++i)
    {
        if (i != len - 1)
        {
            {
                int ind = lower_bound(b.begin(), b.end(), h - a[i - len]) - b.begin();
                upd(1, 0, SZ - 1, ind, len - 1, -1);
            }
            {
                int ind = lower_bound(b.begin(), b.end(), h - a[i]) - b.begin();
                upd(1, 0, SZ - 1, ind, len - 1, 1);
            }
        }
        if (t[1].v + t[1].add > 0)
            ++ans;
    }
    cout << ans << endl;
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <algorithm>
#include <queue>
#include <functional>
#include <sstream>
#include <ctime>
#define lol long long
using namespace std;

struct Node
{
    int v, add;
    Node(int x) : v(x), add(0){};
    Node(){};
};

int len;
Node t[2 * 262144];

void build(int ind, int l, int r)
{
    if (l != r)
    {
        int m = (l + r) / 2;
        build(2 * ind, l, m);
        build(2 * ind + 1, m + 1, r);
        t[ind] = min(t[2 * ind].v, t[2 * ind + 1].v);
    }
    else
        t[ind] = Node(l < len ? -l : 228);
}

void upd(int ind, int tl, int tr, int l, int r, int add)
{
    if (l > r)
        return;
    if (tl == l && tr == r)
    {
        t[ind].add += add;
    }
    else
    {
        if (t[ind].add)
        {
            t[2 * ind].add += t[ind].add;
            t[2 * ind + 1].add += t[ind].add;
            t[ind].v += t[ind].add;
            t[ind].add = 0;
        }
        int m = (tl + tr) / 2;
        upd(2 * ind, tl, m, l, min(r, m), add);
        upd(2 * ind + 1, m + 1, tr, max(l, m + 1), r, add);
        t[ind] = min(t[2 * ind].v + t[2 * ind].add, t[2 * ind + 1].v + t[2 * ind + 1].add);
    }
}

int SZ = 262144;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, h;
    cin >> n >> len >> h;
    vector<int> b(len);
    for (int i = 0; i < len; ++i)
        cin >> b[i];
    sort(b.begin(), b.end());

    vector<int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];

    build(1, 0, SZ - 1);

    for (int i = 0; i < len; ++i)
    {
        int ind = lower_bound(b.begin(), b.end(), h - a[i]) - b.begin();
        upd(1, 0, SZ - 1, ind, len - 1, 1);
    }

    int ans = 0;
    for (int i = len - 1; i < n; ++i)
    {
        if (i != len - 1)
        {
            int ind = lower_bound(b.begin(), b.end(), h - a[i - len]) - b.begin();
            upd(1, 0, SZ - 1, ind, len - 1, -1);
            ind = lower_bound(b.begin(), b.end(), h - a[i]) - b.begin();
            upd(1, 0, SZ - 1, ind, len - 1, 1);
        }
        if (t[1].v + t[1].add > 0)
            ++ans;
    }
    cout << ans << endl;
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <algorithm>
#include <queue>
#include <functional>
#include <sstream>
#include <ctime>
#define lol long long
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, len, h;
    cin >> n >> len >> h;
    vector<int> b(len);
    for (int i = 0; i < len; ++i)
        cin >> b[i];
    sort(b.rbegin(), b.rend());
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    multiset<int> s(a.begin(), a.begin() + len);
    int ans = 0;
    for (int i = len - 1; i < n; ++i)
    {
        if (i != len - 1)
        {
            s.erase(s.find(a[i - len]));
            s.insert(a[i]);
        }
        bool fail = 0;
        int ind = 0;
        for (multiset<int>::iterator it = s.begin(); it != s.end(); ++it)
            if ((*it) + b[ind++] < h)
            {
                fail = 1;
                break;
            }

        if (!fail)
            ++ans;
    }
    cout << ans << endl;
}