#include<bits/stdc++.h>
using namespace std;
const int M = 1000000007;

class suffix_array {
    // compare (rank[i], rank[i + k]) and (rank[j], rank[j + k])
    static bool compare_sa(int n, const vector<int>& rank, int i, int j, int k) {
        if (rank[i] != rank[j]) return rank[i] < rank[j];
        int ri = i + k <= n ? rank[i + k] : -1;
        int rj = j + k <= n ? rank[j + k] : -1;
        return ri < rj;
    }
public:
    static vector<int> construct_sa(const string& s) {
        int n = s.length();
        vector<int> sa(n + 1), rank(n + 1);
        for (int i = 0; i <= n; ++i) {
            sa[i] = i;
            rank[i] = i < n ? s[i] : -1;
        }
        for (int k = 1; k <= n; k <<= 1) {
            sort(sa.begin(), sa.end(), [&n, &k, &rank](const int& a, const int& b){ return compare_sa(n, rank, a, b, k); });

            vector<int> tmp(n + 1);
            for (int i = 1; i <= n; ++i)
                tmp[sa[i]] = tmp[sa[i - 1]] + compare_sa(n, rank, sa[i - 1], sa[i], k);
            for (int i = 0; i <= n; ++i)
                rank[i] = tmp[i];
        }
        return sa;
    }
    static vector<int> construct_lcp(const string& s, const vector<int>& sa) {
        int n = s.length();
        vector<int> rank(n + 1), lcp(n + 1);
        for (int i = 0; i <= n; ++i) rank[sa[i]] = i;

        int h = 0;
        for (int i = 0; i < n; ++i) {
            if (h > 0) --h;
            for (int j = sa[rank[i] - 1]; j + h < n && i + h < n; ++h)
                if (s[j + h] != s[i + h]) break;

            lcp[rank[i] - 1] = h;
        }
        return lcp;
    }
};


int main() {
    string s, t;
    cin >> s >> t;
    string st = s + t, rts = t + s;
    reverse(rts.begin(), rts.end());
    vector<int> sa_st = suffix_array::construct_sa(st);
    vector<int> lcp_st = suffix_array::construct_lcp(st, sa_st);
    vector<int> sa_rts = suffix_array::construct_sa(rts);
    vector<int> lcp_rts = suffix_array::construct_lcp(rts, sa_rts);
    int st_i = -1, rts_i = -1;
    for (int i = 0; i < (int)sa_st.size(); ++i) {
        if (sa_st[i] == (int)s.length()) {
            st_i = i;
            break;
        }
    }
    for (int i = 0; i < (int)sa_rts.size(); ++i) {
        if (sa_rts[i] == (int)s.length()) {
            rts_i = i;
            break;
        }
    }
    vector<int> h((int)s.length() - (int)t.length() + 1);
    int l = M;
    for (int i = st_i + 1; i < (int)sa_st.size(); ++i) {
        l = min(l, lcp_st[i - 1]);
        if (l == 0) break;
        if (sa_st[i] < (int)h.size())
            h[sa_st[i]] += l;
    }
    l = M;
    for (int i = st_i - 1; i >= 0; --i) {
        l = min(l, lcp_st[i]);
        if (l == 0) break;
        if (sa_st[i] < (int)h.size())
            h[sa_st[i]] += l;
    }
    l = M;
    for (int i = rts_i + 1; i < (int)sa_rts.size(); ++i) {
        l = min(l, lcp_rts[i - 1]);
        if (l == 0) break;
        int u = (int)s.length() - sa_rts[i] - (int)t.length();
        if (u >= 0 && u < (int)h.size())
            h[u] += l;
    }
    l = M;
    for (int i = rts_i - 1; i >= 0; --i) {
        l = min(l, lcp_rts[i]);
        if (l == 0) break;
        int u = (int)s.length() - sa_rts[i] - (int)t.length();
        if (u >= 0 && u < (int)h.size())
            h[u] += l;
    }
    int ans = 0;
    for (int i : h) {
        // cout << i << "\n";
        if (i == (int)t.length() - 1) ++ans;
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 13236