Link to this code: https://cses.fi/paste/e7800486b44c1357100009d/
#include <algorithm>
#include <functional>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#ifndef ONLINE_JUDGE
#define test(...) do { cerr << "Line(" << __LINE__ << ") [" #__VA_ARGS__ "] =>"; ([](auto&&... args){ ((cerr << ' ' << args), ...); }(__VA_ARGS__)); cerr << endl; } while(0)
#define testv(x) do { cerr << "Line(" << __LINE__ << ") " #x " => ["; int _i=0; for (auto& _e : (x)) cerr << (_i++ ? ", " : "") << _e; cerr << "]" << endl; } while(0)
#else
#define test(...) 0
#define testv(...) 0
#endif
#define printv(x) { for (auto i : (x)) cout << i << ' '; cout << endl; }
#define SQ(x) ((x) * (x))
#define SZ(x) ((int)x.size())
#define eb emplace_back
#define ALL(x) begin(x), end(x)
#define rALL(x) rbegin(x), rend(x)
#define fst first
#define sec second
 
using namespace std;
using lli = long long int;
 
vector<int> KMP(string s) {
        int N = SZ(s);
        vector<int> pi(N);
        pi[0] = 0;
        for (int i = 1; i < N; i++) {
                int j = pi[i - 1];
                while (j > 0 and s[i] != s[j]) j = pi[j - 1];
                if (s[i] == s[j]) j++;
                pi[i] = j;
        }
        return pi;
}
 
void solution() {
        string S, T; cin >> S >> T;
        int N = SZ(S), M = SZ(T);
        string st = T + '#' + S;
        vector<int> pi = KMP(st);
        int cnt = 0;
        for (int i = M + 1; i < N + M + 1; i++) {
                if (pi[i] == M) cnt++;
        }
        cout << cnt << '\n';
}
 
int main() {
        cin.tie(nullptr)->sync_with_stdio(false);
        solution();
        return 0;
}