#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

//I read this page.
//http://snuke.hatenablog.com/entry/2014/12/03/214243

int T_length,P_length;
char *T,*P,*reverse_T,*reverse_P;

int main(){

	T = new char[3000001];
	reverse_T = new char[3000001];
	scanf("%s",T);

	for(T_length = 0; T[T_length] != '\0'; T_length++);
	for(int i = T_length-1; i >= 0; i--)reverse_T[T_length-1-i] = T[i];
	reverse_T[T_length] = '\0';

	P = new char[3000001];
	reverse_P = new char[3000001];

	scanf("%s",P);

	for(P_length = 0;P[P_length] != '\0';P_length++);
	for(int i = P_length-1; i >= 0; i--)reverse_P[P_length-1-i] = P[i];
	reverse_P[P_length] = '\0';

	int* z_algorithm_P = new int[P_length];

	z_algorithm_P[0] = P_length;
	int index = 1,diff = 0,diff_2;

	while(index < P_length){
		while(index+diff < P_length && P[index+diff] == P[diff])diff++;
		z_algorithm_P[index] = diff;

		if(diff == 0){
			index++;
			continue;
		}else{

			for(diff_2 = 1; diff_2 < diff; diff_2++){
				if(index+diff == P_length || P[index+diff] != P[diff-diff_2]){
					z_algorithm_P[index+diff_2] = min(z_algorithm_P[diff_2],diff-diff_2);
				}else{
					break;
				}
			}

			index += diff_2;
			diff -= diff_2;
		}
	}

	int* z_algorithm_T = new int[T_length];

	index = 0,diff = 0;

	while(index < T_length){
		while(diff < P_length && index+diff < T_length && T[index+diff] == P[diff])diff++;
		z_algorithm_T[index] = diff;

		if(diff == 0){
			index++;
			continue;
		}else{

			for(diff_2 = 1; diff_2 < diff; diff_2++){
				if(diff == P_length || index+diff == T_length || T[index+diff] != P[diff-diff_2]){
					z_algorithm_T[index+diff_2] = min(z_algorithm_P[diff_2],diff-diff_2);
				}else{
					break;
				}
			}

			index += diff_2;
			diff -= diff_2;
		}
	}

	int* reverse_z_algorithm_P = new int[P_length];

	reverse_z_algorithm_P[0] = P_length;
	index = 1,diff = 0;

	while(index < P_length){
		while(index+diff < P_length && reverse_P[index+diff] == reverse_P[diff])diff++;
		reverse_z_algorithm_P[index] = diff;

		if(diff == 0){
			index++;
			continue;
		}else{

			for(diff_2 = 1; diff_2 < diff; diff_2++){
				if(index+diff == P_length || reverse_P[index+diff] != reverse_P[diff-diff_2]){
					reverse_z_algorithm_P[index+diff_2] = min(reverse_z_algorithm_P[diff_2],diff-diff_2);
				}else{
					break;
				}
			}

			index += diff_2;
			diff -= diff_2;
		}
	}

	int* reverse_z_algorithm_T = new int[T_length];
	index = 0,diff = 0;

	while(index < T_length){
		while(diff < P_length && index+diff < T_length && reverse_T[index+diff] == reverse_P[diff])diff++;
		reverse_z_algorithm_T[index] = diff;

		if(diff == 0){
			index++;
			continue;
		}else{

			for(diff_2 = 1; diff_2 < diff; diff_2++){
				if(diff == P_length || index+diff == T_length || reverse_T[index+diff] != reverse_P[diff-diff_2]){
					reverse_z_algorithm_T[index+diff_2] = min(reverse_z_algorithm_P[diff_2],diff-diff_2);
				}else{
					break;
				}
			}

			index += diff_2;
			diff -= diff_2;
		}
	}

	int ans = 0,limit = T_length-P_length;

	for(int i = 0; i <= limit; i++){
		if(z_algorithm_T[i] + reverse_z_algorithm_T[T_length-(P_length+i)] == P_length-1)ans++;
	}

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

	return 0;
}

Measured memory_bytes: 7588