#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<stack>
using namespace std;
#define NN 1000500
#define gson(i,root) for(ll i=ptx[root];~i;i=ed[i].next)
typedef __int64 ll;
const ll N=1000000;
const ll e=ll(1e9+7);
struct edge{
    ll v,next,w;
    edge(){}
    edge(ll v,ll next,ll w){
        this->v=v;
        this->next=next;
        this->w=w;
    }
}ed[NN*2];
ll ptx[NN],lnum;
void addline(ll x,ll y,ll w){
    ed[lnum]=edge(y,ptx[x],w);
    ptx[x]=lnum++;
}

ll dfn[N],low[N],belong[N]; //tarjan 求连通
ll inde[N]; // 入度
ll ins[N];  // 入栈标记
ll dcnt,bcnt; // 时间戳 和 连通块个数
stack<ll> sta;
void initial(){
	memset(ptx,-1,sizeof(ptx));
	lnum=0;
	while(!sta.empty()) sta.pop();
	dcnt=bcnt=0;
	memset(ins,0,sizeof(ins));
	memset(belong,0,sizeof(belong));
}
void Tarjan(ll u){
	sta.push(u);
	ins[u]=1;
	low[u]=dfn[u]=++dcnt;
	gson(i,u){
		ll v=ed[i].v;
		if(!dfn[v]){
			Tarjan(v);
			low[u]=min(low[v],low[u]);
		}
		else if(ins[v]){
			low[u]=min(low[u],dfn[v]);
		}
	}
	if(low[u]==dfn[u]){
		++bcnt;
		ll v;
		do{
			v=sta.top();
			ins[v]=0;
			belong[bcnt]++; //连通块标记
			sta.pop();
		}while(u!=v);
	}
}
ll n,m;
ll powermod(ll a,ll b){
	ll ans=1;
	while(b>0){
		if(b%2==1) ans=ans*a%e;
		a=a*a%e;
		b>>=1;
	}
	return ans;
}
int main(void){
	initial();
	scanf("%I64d",&n);
	for(ll i=1;i<=n;i++){
		ll x;
		scanf("%I64d",&x);
		addline(i,x,0);
	}
	for(ll i=1;i<=n;i++){
		if(!dfn[i]) Tarjan(i);
	}
	ll sum=0;
	for(ll i=1;i<=bcnt;i++){
		if(belong[i]>1) sum+=belong[i];
	}
	ll y=n-sum;
	printf("%I64d\n",(((powermod(2,sum)%e-2%e+e)%e)*((powermod(2,y))%e))%e);
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int maxn = 200000 + 500;
const int mod = 1e9 + 7;
int n;
int a[maxn];
int depth[maxn], top[maxn], size[maxn];
int st[maxn];
bool f[maxn];
int tot = 0;
int cur = 0;
long long pow2[maxn];
long long ans = 0;
void dfs(int x) {
	top[x] = depth[x] = ++tot;
	cur++;
	st[cur] = x;
	f[x] = 1;
	if (!f[a[x]]) {
		dfs(a[x]);
		top[x] = std :: min(top[x], top[a[x]]);
	} else {
		top[x] = std :: min(depth[a[x]], top[x]);
	}
	if (top[x] == depth[x]) {
		while (1) {
			int k = st[cur];
			cur--;
			if (k == x) break;
			size[k] = 0;
			size[x]++;
		}
	}
}
int main () {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 1; i <= n; i++) size[i] = 1;
	for (int i = 1; i <= n; i++)
		if (!f[i]) dfs(i);
	//for (int i = 1; i <= n; i++) cout << i << ' ' << size[i] << endl;
	pow2[0] = 1;
	for (int i = 1; i <= 10000; i++) pow2[i] = (pow2[i-1] * 2) % mod;
	//for (int i = 1; i <= 1000; i++) cout << pow2[i] << endl;
	int lef = 0;
	for (int i = 1; i <= n; i++ ) if (size[i] == 1) lef++;
	ans = pow2[lef] % mod;
	for (int i = 1; i <= n; i++)
		if (size[i] > 1) ans =  (ans * (pow2[size[i]] - 2)) % mod ;
	cout << ((ans % mod) + mod ) % mod << endl;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int maxn = 200000 + 500;
int n;
int a[maxn];
int depth[maxn], top[maxn], size[maxn];
int st[maxn];
bool f[maxn];
int tot = 0;
int cur = 0;
long long pow2[maxn];
long long ans = 0;
void dfs(int x) {
	top[x] = depth[x] = ++tot;
	cur++;
	st[cur] = x;
	f[x] = 1;
	if (!f[a[x]]) {
		dfs(a[x]);
		top[x] = std :: min(top[x], top[a[x]]);
	} else {
		top[x] = std :: min(depth[a[x]], top[x]);
	}
	if (top[x] == depth[x]) {
		while (1) {
			int k = st[cur];
			cur--;
			if (k == x) break;
			size[k] = 0;
			size[x]++;
		}
	}
}
int main () {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 1; i <= n; i++) size[i] = 1;
	for (int i = 1; i <= n; i++)
		if (!f[i]) dfs(i);
	//for (int i = 1; i <= n; i++) cout << i << ' ' << size[i] << endl;
	pow2[0] = 1;
	for (int i = 1; i <= 60; i++) pow2[i] = pow2[i-1] * 2;
	int lef = 0;
	for (int i = 1; i <= n; i++ ) if (size[i] == 1) lef++;
	ans = pow2[lef];
	for (int i = 1; i <= n; i++)
		if (size[i] > 1) ans *= (pow2[size[i]] - 2);
	cout << ans << endl;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int maxn = 200000 + 500;
int n;
int a[maxn];
int depth[maxn], top[maxn], size[maxn];
int st[maxn];
bool f[maxn];
int tot = 0;
int cur = 0;
long long pow2[maxn];
long long ans = 0;
void dfs(int x) {
	top[x] = depth[x] = ++tot;
	cur++;
	st[cur] = x;
	f[x] = 1;
	if (!f[a[x]]) {
		dfs(a[x]);
		top[x] = std :: min(top[x], top[a[x]]);
	} else {
		top[x] = std :: min(depth[a[x]], top[x]);
	}
	if (top[x] == depth[x]) {
		while (1) {
			int k = st[cur];
			cur--;
			if (k == x) break;
			size[k] = 0;
			size[x]++;
		}
	}
}
int main () {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 1; i <= n; i++) size[i] = 1;
	for (int i = 1; i <= n; i++)
		if (!f[i]) dfs(i);
	//for (int i = 1; i <= n; i++) cout << i << ' ' << size[i] << endl;
	pow2[0] = 1;
	for (int i = 1; i <= 100; i++) pow2[i] = pow2[i-1] * 2;
	int lef = 0;
	for (int i = 1; i <= n; i++ ) if (size[i] == 1) lef++;
	ans = pow2[lef];
	for (int i = 1; i <= n; i++)
		if (size[i] > 1) ans *= (pow2[size[i]] - 2);
	cout << ans << endl;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int maxn = 20000 + 500;
int n;
int a[maxn];
int depth[maxn], top[maxn], size[maxn];
int st[maxn];
bool f[maxn];
int tot = 0;
int cur = 0;
long long pow2[maxn];
long long ans = 0;
void dfs(int x) {
	top[x] = depth[x] = ++tot;
	cur++;
	st[cur] = x;
	f[x] = 1;
	if (!f[a[x]]) {
		dfs(a[x]);
		top[x] = std :: min(top[x], top[a[x]]);
	} else {
		top[x] = std :: min(depth[a[x]], top[x]);
	}
	if (top[x] == depth[x]) {
		while (1) {
			int k = st[cur];
			cur--;
			if (k == x) break;
			size[k] = 0;
			size[x]++;
		}
	}
}
int main () {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 1; i <= n; i++) size[i] = 1;
	for (int i = 1; i <= n; i++)
		if (!f[i]) dfs(i);
	//for (int i = 1; i <= n; i++) cout << i << ' ' << size[i] << endl;
	pow2[0] = 1;
	for (int i = 1; i <= 60; i++) pow2[i] = pow2[i-1] * 2;
	int lef = 0;
	for (int i = 1; i <= n; i++ ) if (size[i] == 1) lef++;
	ans = pow2[lef];
	for (int i = 1; i <= n; i++)
		if (size[i] > 1) ans *= (pow2[size[i]] - 2);
	cout << ans << endl;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int maxn = 200000 + 500;
const int mod = 1e9 + 7;
int n;
int a[maxn];
int depth[maxn], top[maxn], size[maxn];
int st[maxn];
bool f[maxn];
int tot = 0;
int cur = 0;
long long pow2[maxn];
long long ans = 0;
void dfs(int x) {
	top[x] = depth[x] = ++tot;
	cur++;
	st[cur] = x;
	f[x] = 1;
	if (!f[a[x]]) {
		dfs(a[x]);
		top[x] = std :: min(top[x], top[a[x]]);
	} else {
		top[x] = std :: min(depth[a[x]], top[x]);
	}
	if (top[x] == depth[x]) {
		while (1) {
			int k = st[cur];
			cur--;
			if (k == x) break;
			size[k] = 0;
			size[x]++;
		}
	}
}
int main () {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 1; i <= n; i++) size[i] = 1;
	for (int i = 1; i <= n; i++)
		if (!f[i]) dfs(i);
	//for (int i = 1; i <= n; i++) cout << i << ' ' << size[i] << endl;
	pow2[0] = 1;
	for (int i = 1; i <= 200000; i++) pow2[i] = (pow2[i-1] * 2) % mod;
	//for (int i = 1; i <= 1000; i++) cout << pow2[i] << endl;
	int lef = 0;
	for (int i = 1; i <= n; i++ ) if (size[i] == 1) lef++;
	ans = pow2[lef] % mod;
	for (int i = 1; i <= n; i++)
		if (size[i] > 1) ans =  (ans * (pow2[size[i]] - 2)) % mod ;
	cout << ((ans % mod) + mod ) % mod << endl;
	return 0;
}


#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<unordered_set>
#include<unordered_map>
#define nl cout<<"\n";
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
	string a,b;
	cin>>a;
	cin>>b;
	int n= b.size();
	vector<int> one,zero;
	if(b[0]=='0'){
		zero.push_back(1);
	    one.push_back(0);
	}
	else{
		one.push_back(1);
	    zero.push_back(0);
	}
	for(int i=1;i<n;i++){
		if(b[i]=='0'){
			zero.push_back(zero.back() + 1);
			one.push_back(one.back());
		}
		else{
			one.push_back(one.back() + 1);
			zero.push_back(zero.back());
		}
	}
	long long ans=0;
	int m = a.size();
	if(n==m){
		for(int i=0;i<n;i++){
			if(a[i]!=b[i]){
				ans++;
			}
		}
		cout<<ans;
		return 0;
	}
	for(int i=0;i<m;i++){
		if(a[i]=='1'){
			ans+=zero[n-m-i]-(i==0?0:zero[i-1]);
		}
		else{
			ans+=one[n-m-i]-(i==0?0:one[i-1]);
		}
	}
	cout<<ans;
	return 0;
}


#define pb              push_back
#define mp              make_pair
#define ll              long long
#define lp(i,n)         for(int i=0;i<n;i++)
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
const ll OO = 1e9;
const double EPS = (1e-7);
const int mxN = 250000+9;
#include <bits/stdc++.h>
using namespace std;
bool compare(const pair<pair<int,int>, int>&i, const pair<pair<int,int>, int>&j)
{
    return i.second < j.second;
}
int gcd (int a , int b){
    if (b==0) return a;
return gcd(b,a%b);
}
vector<string>sub_str ;
int main()
{
    ll ans=0;
    string s1,s2;
    cin>>s1>>s2;
    int n=s1.size();
    int m=s2.size();
    for (int i=0;i<=m-n;++i){
        sub_str.pb(s2.substr(i,n));
    }
    int size= sub_str.size() ;
    for (int i=0;i<size;i++){
        for (int j=0;j<n;j++){
            ans += abs( ( sub_str[i][j]-'0') - (s1[j]-'0') ) ;
        }
    }
    cout << ans << "\n" ;
    return 0;
}


#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
const int MAXS = 200010;

string A, B;
int F[MAXS][2];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cin >> A >> B;
    for (int i = 1; i <= B.size(); i++) {
        for (int j = 0; j < 2; j++) {
            F[i][j] = F[i - 1][j];
        }
        ++F[i][B[i - 1] - '0'];
    }
    ll res = 0;
    for (int i = 0, c; i < A.size(); i++) {
        c = A[i]-'0';
        for (int j = 0; j < 2; j++) {
            res += abs(c - j) * (F[B.size() - A.size() + i + 1][j] - F[i][j]);
        }
    }
    cout << res << '\n';
    return 0;
}


#define pb              push_back
#define mp              make_pair
#define ll              long long
#define lp(i,n)         for(int i=0;i<n;i++)
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
const ll OO = 1e9;
const double EPS = (1e-7);
const int mxN = 250000+9;
#include <bits/stdc++.h>
using namespace std;
bool compare(const pair<pair<int,int>, int>&i, const pair<pair<int,int>, int>&j)
{
    return i.second < j.second;
}
int gcd (int a , int b){
    if (b==0) return a;
return gcd(b,a%b);
}
vector<string>sub_str ;
int main()
{
    int ans=0;
    string s1,s2;
    cin>>s1>>s2;
    int n=s1.size();
    int m=s2.size();
    for (int i=0;i<=m-n;++i){
        sub_str.pb(s2.substr(i,n));
    }
    for (int i=0;i<(int)sub_str.size();i++){
        for (int j=0;j<n;j++){
            ans += abs( ( sub_str[i][j]-'0') - (s1[j]-'0') ) ;
        }
    }
    cout << ans << "\n" ;
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <set>
#include <cmath>

#define faster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define show(v) for(int i : v)cout << i << ' ';cout << '\n';
#define MAXN 200005
using namespace std;
using namespace std::chrono;
typedef long long ll;

int inf = 1e9;
int mod = 1e9 + 7;

void solve() {
    string a, b; cin >> a >> b;
    ll n = (ll) a.length();
    ll m = (ll) b.length();
    ll l = m - n + 1;
    ll ones = 0;
    for(ll i = 0;i < l;i++)
        if(b[i] == '1') ones++;
    ll ans = 0;
    for(ll i = 0;i < n;i++) {
        if(a[i] == '0')
            ans += ones;
        else ans += (l - ones);
        if(b[i] == '1') ones--;
        if(b[i + l] == '1') ones++;
    }
    cout << ans << endl;
}

int main() {
    faster
    solve();
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <set>
#include <cmath>

#define faster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define show(v) for(int i : v)cout << i << ' ';cout << '\n';
#define MAXN 200005
using namespace std;
using namespace std::chrono;
typedef long long ll;

int inf = 1e9;
int mod = 1e9 + 7;

void solve() {
    string a, b; cin >> a >> b;
    ll n = (int) a.length();
    ll m = (int) b.length();
    ll l = m - n + 1;
    ll ones = 0;
    for(ll i = 0;i < l;i++)
        if(b[i] == '1') ones++;
    ll ans = 0;
    for(ll i = 0;i < n;i++) {
        if(a[i] == '0')
            ans += ones;
        else ans += (l - ones);
        if(b[i] == '1') ones--;
        if(b[i + l] == '1') ones++;
    }
    cout << ans << endl;
}

int main() {
    faster
    solve();
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <set>
#include <cmath>

#define faster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define show(v) for(int i : v)cout << i << ' ';cout << '\n';
#define MAXN 200005
using namespace std;
typedef long long ll;

int inf = 1e9;
int mod = 1e9 + 7;

void solve() {
    string a, b; cin >> a >> b;
    ll n = (ll) a.length();
    ll m = (ll) b.length();
    ll l = m - n + 1;
    ll ones = 0;
    for(ll i = 0;i < l;i++)
        if(b[i] == '1') ones++;
    ll ans = 0;
    for(ll i = 0;i < n;i++) {
        if(a[i] == '0')
            ans += ones;
        else ans += (l - ones);
        if(b[i] == '1') ones--;
        if(b[i + l] == '1') ones++;
    }
    cout << ans << endl;
}

int main() {
    faster
    solve();
    return 0;
}


#include "bits/stdc++.h"
#define ll long long
#define PI 3.1415926535897932384626433832795l
#define MAX_NUM 1000000000
#define line printf("-----------------\n");
using namespace std;
int SET(int N, int pos) { return N = N | (1 << pos); }
int RESET(int N, int pos) { return N = N & ~(1 << pos); }
bool CHECK(int N, int pos) { return (bool)(N & (1 << pos)); }
template <typename T>
inline T __lcm(T a, T b)
{
    return (a * b) / __gcd(a, b);
}
struct node
{
    int x, y, i;
};
int dx[] = {0, 1, 0, -1, -1, 1, -1, 1};
int dy[] = {1, 0, -1, 0, 1, 1, -1, -1};

ll prefix0[1000000];
ll prefix1[1000000];

ll fun(ll id, ll left, ll right)
{
    if (id == 1)
    {
        return prefix0[right] - prefix0[left - 1];
    }
    else
    {
        return prefix1[right] - prefix1[left - 1];
    }
}

void solve()
{
    string a, b;
    cin >> a >> b;

    ll n, m;
    n = b.size();
    m = a.size();

    a = "a" + a;
    b = "b" + b;
    ll temp = 0;
    for (int i = 1; i <= m; i++)
    {
        if (a[i] == '0')
        {
            temp++;
        }
        prefix0[i] = temp;
    }
    temp = 0;
    for (int i = 1; i <= m; i++)
    {
        if (a[i] == '1')
        {
            temp++;
        }
        prefix1[i] = temp;
    }

    for (int i = 1; i <= m; i++)
    {
        //cout<<prefix1[i]<<endl;
    }

    ll p = 1, q = 0;

    ll ans = 0;
    for (int i = 1; i <= n; i++)
    {
        if (i + m - 1 <= n)
        {
            if (q + 1 <= m)
                q++;
            ans += fun(b[i] - '0', p, q);
        }
        else
        {
            p++;
            if (q + 1 <= m)
                q++;
            ans += fun(b[i] - '0', p, q);
        }
        //cout << "p = " << p << "  q = " << q << endl;
    }
    cout << ans << endl;
}

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


#include "bits/stdc++.h"
#define ll long long
#define PI 3.1415926535897932384626433832795l
#define MAX_NUM 1000000000
#define line printf("-----------------\n");
using namespace std;
int SET(int N, int pos) { return N = N | (1 << pos); }
int RESET(int N, int pos) { return N = N & ~(1 << pos); }
bool CHECK(int N, int pos) { return (bool)(N & (1 << pos)); }
template <typename T>
inline T __lcm(T a, T b)
{
    return (a * b) / __gcd(a, b);
}
struct node
{
    int x, y, i;
};
int dx[] = {0, 1, 0, -1, -1, 1, -1, 1};
int dy[] = {1, 0, -1, 0, 1, 1, -1, -1};

ll prefix0[1000000];
ll prefix1[1000000];

ll fun(ll id, ll left, ll right)
{
    if (id == 1)
    {
        return prefix0[right] - prefix0[left - 1];
    }
    else
    {
        return prefix1[right] - prefix1[left - 1];
    }
}

void solve()
{
    string a, b;
    cin >> a >> b;

    ll n, m;
    n = b.size();
    m = a.size();

    a = "a" + a;
    b = "b" + b;
    ll temp = 0;
    for (int i = 1; i <= m; i++)
    {
        if (a[i] == '0')
        {
            temp++;
        }
        prefix0[i] = temp;
    }
    temp = 0;
    for (int i = 1; i <= m; i++)
    {
        if (a[i] == '1')
        {
            temp++;
        }
        prefix1[i] = temp;
    }

    for(int i=1;i<=m;i++)
    {
        //cout<<prefix1[i]<<endl;
    }

    ll p = 1, q = 0;

    ll ans = 0;
    for (int i = 1; i <= n; i++)
    {
        if (i + m - 1 <= n)
        {
            if (q + 1 <= m)
                q++;
            ans += fun(b[i] - '0', p, q);
        }
        else
        {
            p++;
            if(q<p)
            {
                q=p;
            }
            ans+=fun(b[i]-'0',p,q);
        }
        //cout<<"p = "<<p<<"  q = "<<q<<endl;
    }
    cout<<ans<<endl;
}

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


#include "bits/stdc++.h"
#define ll long long
#define PI 3.1415926535897932384626433832795l
#define MAX_NUM 1000000000
#define line printf("-----------------\n");
using namespace std;
int SET(int N, int pos) { return N = N | (1 << pos); }
int RESET(int N, int pos) { return N = N & ~(1 << pos); }
bool CHECK(int N, int pos) { return (bool)(N & (1 << pos)); }
template <typename T>
inline T __lcm(T a, T b)
{
    return (a * b) / __gcd(a, b);
}
struct node
{
    int x, y, i;
};
int dx[] = {0, 1, 0, -1, -1, 1, -1, 1};
int dy[] = {1, 0, -1, 0, 1, 1, -1, -1};

ll prefix0[1000000];
ll prefix1[1000000];

ll fun(ll id, ll left, ll right)
{
    if (id == 1)
    {
        return prefix0[right] - prefix0[left - 1];
    }
    else
    {
        return prefix1[right] - prefix1[left - 1];
    }
}

void solve()
{
    string a, b;
    cin >> a >> b;

    ll n, m;
    n = b.size();
    m = a.size();

    a = "a" + a;
    b = "b" + b;
    ll temp = 0;
    for (int i = 1; i <= m; i++)
    {
        if (a[i] == '0')
        {
            temp++;
        }
        prefix0[i] = temp;
    }
    temp = 0;
    for (int i = 1; i <= m; i++)
    {
        if (a[i] == '1')
        {
            temp++;
        }
        prefix1[i] = temp;
    }

    for(int i=1;i<=m;i++)
    {
        //cout<<prefix1[i]<<endl;
    }

    ll p = 1, q = 0;

    ll ans = 0;
    for (int i = 1; i <= n; i++)
    {
        if (i + m - 1 <= n)
        {
            if (q + 1 <= m)
                q++;
            ans += fun(b[i] - '0', p, q);
        }
        else
        {
            p++;
            if(q<p)
            {
                q=p;
            }
            ans+=fun(b[i]-'0',p,q);
        }
        cout<<"p = "<<p<<"  q = "<<q<<endl;
    }
    cout<<ans<<endl;
}

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


#include "bits/stdc++.h"
#define ll long long
#define PI 3.1415926535897932384626433832795l
#define MAX_NUM 1000000000
#define line printf("-----------------\n");
using namespace std;
int SET(int N, int pos) { return N = N | (1 << pos); }
int RESET(int N, int pos) { return N = N & ~(1 << pos); }
bool CHECK(int N, int pos) { return (bool)(N & (1 << pos)); }
template <typename T>
inline T __lcm(T a, T b)
{
    return (a * b) / __gcd(a, b);
}
struct node
{
    int x, y, i;
};
int dx[] = {0, 1, 0, -1, -1, 1, -1, 1};
int dy[] = {1, 0, -1, 0, 1, 1, -1, -1};

int prefix0[1000000];
int prefix1[1000000];

int fun(int id, int left, int right)
{
    if (id == 1)
    {
        return prefix0[right] - prefix0[left - 1];
    }
    else
    {
        return prefix1[right] - prefix1[left - 1];
    }
}

void solve()
{
    string a, b;
    cin >> a >> b;

    int n, m;
    n = b.size();
    m = a.size();

    a = "a" + a;
    b = "b" + b;
    int temp = 0;
    for (int i = 1; i <= m; i++)
    {
        if (a[i] == '0')
        {
            temp++;
        }
        prefix0[i] = temp;
    }
    temp = 0;
    for (int i = 1; i <= m; i++)
    {
        if (a[i] == '1')
        {
            temp++;
        }
        prefix1[i] = temp;
    }

    for(int i=1;i<=m;i++)
    {
        //cout<<prefix1[i]<<endl;
    }

    int p = 1, q = 0;

    ll ans = 0;
    for (int i = 1; i <= n; i++)
    {
        if (i + m - 1 <= n)
        {
            if (q + 1 <= m)
                q++;
            ans += fun(b[i] - '0', p, q);
        }
        else
        {
            p++;
            if(q<p)
            {
                q=p;
            }
            ans+=fun(b[i]-'0',p,q);
        }
        //cout<<"p = "<<p<<"  q = "<<q<<endl;
    }
    cout<<ans<<endl;
}

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


#include <iostream>
using namespace std;
int main(void){
    string a,b;
    cin>>a>>b;
    int ones[b.length()];
    ones[0] = a[0]-'0';
    for(int i =1;i<b.length();i++)
        ones[i] = ones[i-1] + (b[i]-'0');
    int zeros[b.length()];
    zeros[0] = !(b[0]-'0');
    for(int i = 1;i<b.length();i++)
        zeros[i] = zeros[i-1] + !(b[i]-'0');
    int sum = 0;
    // ones;
    for(int i=0;i<a.length();++i) {
        int dif = b.length() - a.length() + i;
        if (a[i] == '1') {
        if (i == 0)
            sum += zeros[dif];
        else sum += zeros[dif] - zeros[i - 1];}
    }
    //zeros
    for(int i=0;i<a.length();++i){
        int dif = b.length()-a.length()+i;
        if(a[i]=='0') {
            if (i == 0)
                sum += ones[dif];
            else sum += ones[dif] - ones[i - 1];
        }
    }
    cout<<sum<<'\n';

return 0;}


#include <iostream>
using namespace std;
int main(void){
    string a,b;
    cin>>a>>b;
    int ones[b.length()];
    ones[0] = b[0]-'0';
    for(int i =1;i<b.length();i++)
        ones[i] = ones[i-1] + (b[i]-'0');
    int zeros[b.length()];
    zeros[0] = !(b[0]-'0');
    for(int i = 1;i<b.length();i++)
        zeros[i] = zeros[i-1] + !(b[i]-'0');
    long long int sum = 0;
    // ones;
    for(int i=0;i<a.length();++i) {
        int dif = b.length() - a.length() + i;
        if (a[i] == '1') {
        if (i == 0)
            sum += zeros[dif];
        else sum += zeros[dif] - zeros[i - 1];}
    }
    //zeros
    for(int i=0;i<a.length();++i){
        int dif = b.length()-a.length()+i;
        if(a[i]=='0') {
            if (i == 0)
                sum += ones[dif];
            else sum += ones[dif] - ones[i - 1];
        }
    }
    cout<<sum<<'\n';

return 0;}


#include <iostream>
using namespace std;
int main(void){
    string a,b;
    cin>>a>>b;
    int ones[b.length()];
    ones[0] = b[0]-'0';
    for(int i =1;i<b.length();i++)
        ones[i] = ones[i-1] + (b[i]-'0');
    int zeros[b.length()];
    zeros[0] = !(b[0]-'0');
    for(int i = 1;i<b.length();i++)
        zeros[i] = zeros[i-1] + !(b[i]-'0');
    int sum = 0;
    // ones;
    for(int i=0;i<a.length();++i) {
        int dif = b.length() - a.length() + i;
        if (a[i] == '1') {
        if (i == 0)
            sum += zeros[dif];
        else sum += zeros[dif] - zeros[i - 1];}
    }
    //zeros
    for(int i=0;i<a.length();++i){
        int dif = b.length()-a.length()+i;
        if(a[i]=='0') {
            if (i == 0)
                sum += ones[dif];
            else sum += ones[dif] - ones[i - 1];
        }
    }
    cout<<sum<<'\n';

return 0;}


#include "bits/stdc++.h"
using namespace std;

#define  F  first
#define  S  second
#define  mp make_pair
#define  pb push_back
typedef long long int ll;
const int N = 1e6+6,inf = 1e9+7;
int cnt[N];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    string A,B;cin>>A>>B;
    int sz = A.size();
    ll res = 0;
    bool flg = 0;
    for(int i=0;i<sz;i++)
        cnt[i+1] += (cnt[i]+(A[i]=='1'));
    for(int i=sz;i<=B.size()-sz+1;i++)
    {
        flg = 1;
        if(B[i-1]=='1')res += (sz-cnt[sz]);
        else res += cnt[sz];
    }
    int len = sz;
    if(flg)
    {
    for(int i=1;i<sz;i++)
    {
        if(B[i-1]=='1')res += (i-cnt[i]);
        else res += cnt[i];
    }
    }
    else
    {
        for(int i=1;i<=sz;i++)
            if(A[i-1]!=B[i-1])
                res++;
    }
    int now = 1,tot = sz-1;
    for(int i=max(sz,(int)B.size()-sz)+2;i<=B.size();i++)
    {
        if(B[i-1]=='1')res += (tot-(cnt[sz]-cnt[now]));
        else res += (cnt[sz]-cnt[now]);
        now++,tot--;
    }
    cout<<res<< "\n";

    return 0;
}


#include "bits/stdc++.h"
using namespace std;

#define  F  first
#define  S  second
#define  mp make_pair
#define  pb push_back
typedef long long int ll;
const int N = 1e6+6,inf = 1e9+7;
int cnt[N];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    string A,B;
    cin>>A>>B;
    int sz = A.size();
    ll res = 0;
    bool flg = 0;
    for(int i=0; i<sz; i++)
        cnt[i+1] += (cnt[i]+(A[i]=='1'));
    for(int i=sz; i<=B.size()-sz+1; i++)
    {
        flg = 1;
        if(B[i-1]=='1')
            res += (sz-cnt[sz]);
        else
            res += cnt[sz];
    }
    int len = sz;
    if(!flg)
        len = B.size()-sz+2;
    for(int i=1; i<len; i++)
    {
        if(B[i-1]=='1')
            res += (i-cnt[i]);
        else
            res += cnt[i];
    }
    int now = 1,tot = sz-1;
    len = max(sz,(int)B.size()-sz)+2;
    if(!flg)
        len = B.size()-sz+2;
    for(int i=len; i<=B.size(); i++)
    {
        if(B[i-1]=='1')
            res += (tot-(cnt[sz]-cnt[now]));
        else
            res += (cnt[sz]-cnt[now]);
        now++,tot--;
    }
    cout<<res<< "\n";

    return 0;
}


#include "bits/stdc++.h"
using namespace std;

#define  F  first
#define  S  second
#define  mp make_pair
#define  pb push_back
typedef long long int ll;
const int N = 1e6+6,inf = 1e9+7;
int cnt[N];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    string A,B;
    cin>>A>>B;
    int sz = A.size();
    ll res = 0;
    bool flg = 0;
    for(int i=0; i<sz; i++)
        cnt[i+1] += (cnt[i]+(A[i]=='1'));
    for(int i=sz; i<=B.size()-sz+1; i++)
    {
        flg = 1;
        if(B[i-1]=='1')
            res += (sz-cnt[sz]);
        else
            res += cnt[sz];
    }
    int len = sz;
    if(!flg)
        len = B.size()-sz+2;
    for(int i=1; i<len; i++)
    {
        if(B[i-1]=='1')
            res += (i-cnt[i]);
        else
            res += cnt[i];
    }
    int now = 1,tot = sz-1;
    len = max(sz,(int)B.size()-sz)+2;
    if(!flg)
    {
        len = B.size()-sz+2;
        tot = len-1;
    }
    for(int i=len; i<=B.size(); i++)
    {
        if(B[i-1]=='1')
            res += (tot-(cnt[sz]-cnt[now]));
        else
            res += (cnt[sz]-cnt[now]);
        now++,tot--;
    }
    cout<<res<< "\n";

    return 0;
}


#include "bits/stdc++.h"
using namespace std;

#define  F  first
#define  S  second
#define  mp make_pair
#define  pb push_back
typedef long long int ll;
const int N = 1e6+6,inf = 1e9+7;
int cnt[N];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    string A,B;
    cin>>A>>B;
    int sz = B.size();
    ll res = 0;
    bool flg = 0;
    for(int i=0; i<sz; i++)
        cnt[i+1] += (cnt[i]+(B[i]=='1'));
    int len = B.size()-A.size()+1;
    for(int i=1;i<=A.size();i++)
    {
        if(A[i-1]=='0')
            res += cnt[len+i-1]-cnt[i-1];
        else
            res += len-(cnt[len+i-1]-cnt[i-1]);
    }
    cout<<res<< "\n";

    return 0;
}


#include "bits/stdc++.h"
using namespace std;

#define  F  first
#define  S  second
#define  mp make_pair
#define  pb push_back
typedef long long int ll;
const int N = 1e6+6,inf = 1e9+7;
int cnt[N];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    string A,B;
    cin>>A>>B;
    int sz = A.size();
    ll res = 0;
    bool flg = 0;
    for(int i=0; i<sz; i++)
        cnt[i+1] += (cnt[i]+(A[i]=='1'));
    for(int i=sz; i<=B.size()-sz+1; i++)
    {
        flg = 1;
        if(B[i-1]=='1')
            res += (sz-cnt[sz]);
        else
            res += cnt[sz];
    }
    int len = sz;
    if(!flg)
        len = B.size()-sz+2;
    for(int i=1; i<len; i++)
    {
        if(B[i-1]=='1')
            res += (i-cnt[i]);
        else
            res += cnt[i];
    }
    int now = 1,tot = sz-1;
    len = max(sz,(int)B.size()-sz)+2;
    if(!flg)
    {
        len = B.size()-sz+2;
        tot = len;
    }
    for(int i=len; i<=B.size(); i++)
    {
        int tmp = 0,ln = tot-now+1;
        if(B[i-1]=='1')
            tmp += (ln-(cnt[tot]-cnt[now]));
        else
            tmp += (cnt[tot]-cnt[now]);
        res += tmp;
        now++,tot++;
        if(tot>sz)tot=sz;
    }
    cout<<res-sz/2<< "\n";

    return 0;
}


#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
#define pii pair<int,int>
#define pll pair<long long,long long>
#define usi unordered_set<int>
#define usl unordered_set<long long>
#define umii unordered_map<int,int>
#define umsi unordered_map<string,int>
#define umll unordered_map<long long,long long>
#define fi first
#define sec second
#define pub push_back
#define pob pop_back
#define B begin
#define E end
#define mp make_pair
#define vi vector<int>
#define vl vector<long long>
#define vii vector<pii>
#define vll vector<pll>
#define deb(x) cout<<#x<<": "<<x<<"\n"
#define endl '\n'
#define PIE 3.141592653
#define MOD 1000000007
#define f(i,a,b,c) for(ll i=a;i<=b;i+=c)
#define frev(i,n,b,c)  for(ll i=n;i>=b;i-=c)
const ll inf = 1000000000000000000;
using namespace std;

//            < = = = = =    GCD     = = = = = >

ll gcd(ll a, ll b)
{
    if (a < b) gcd(b, a);
    if (b == 0)    return a;
    return gcd(b, a % b);
}

//            < = = = = =    LCM     = = = = = >

ll lcm(ll a, ll b)
{
    ll x = (a / gcd(a, b)) * b;
    return x;
}

//            < = = = = =    power  x^n     = = = = = >

ll power(ll x , ll n , ll m = inf) {
    if (x == 0) {
        return 0;
    }
    if (n == 0) {
        return 1;
    }
    ll ans;
    if (n % 2 == 0) {
        ll smallAns = power(x, n / 2, m);
        ans = (smallAns * smallAns) % m;
    } else {
        ll smallAns = power(x, n - 1, m);
        ans = x;
        ans = (ans * smallAns) % m;
    }
    // for negative values also
    return (ans + m) % m;

}

//            < = = = = =    CHECK FOR PRIME     = = = = = >

bool isprime(int n) {
    if (n == 2) {
        return true;
    }
    else if (n % 2 == 0) {
        return false;
    }
    else {
        for (int i = 3; i * i <= n; i += 2) {
            if (n % i == 0) {
                return false;
            }
        }
        return true;
    }
}

//            < = = = = =    SOLVE    = = = = = >

//  void generate() {
//     memset(div, 0, sizeof div);
//     for (int i = 1; i <= N; i++) {
//         for (int j = i; j <= N; j += i) {
//             divisors[j] += 1;
//         }
//     }
// }

// bool cmp(pll x, pll y){
//     ll dx = min(2*(x.first),x.second)-min(x.first,x.second);
//     ll dy = min(2*(y.first),y.second)-min(y.first,y.second);
//     return dx>dy;
// }

// void rec(int ){
//     if(){

//         return 0;
//     }

//     return ;
// }

int solve() {
    fastio
    string a, b;
    cin >> a >> b;
    int ans = 0, k = -1;
    int alen = a.length(), blen = b.length();
    int b0[blen], b1[blen];
    b0[0] = 0;
    b1[0] = 0;
    if (b[0] == '0')b0[0] = 1;
    else b1[0] = 1;
    // cout << b0[0] << " " << b1[0] << endl;
    for (int i = 1; i < blen; ++i)
    {
        if (b[i] == '0') {
            b0[i] = b0[i - 1] + 1;
            b1[i] = b1[i - 1];
        } else {
            b0[i] = b0[i - 1];
            b1[i] = b1[i - 1] + 1;
        }
        // cout << b0[i] << " " << b1[i] << endl;
    }
    if (a[0] == '0') {
        ans += (b1[blen - alen + 0] - 0);
    } else {
        ans += (b0[blen - alen + 0] - 0);
    }
    for (int i = 1; i < alen; ++i)
    {
        if (a[i] == '0') {
            ans += (b1[blen - alen + i] - b1[i - 1]);
        } else {
            ans += (b0[blen - alen + i] - b0[i - 1]);
        }
    }
    cout << ans;
    return 0;
}

//            < = = = = =    MAIN     = = = = = >

int main() {
    fastio

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

    int t = 1;
    //  cin>>t;
    while (t--) {
        solve();
    }

    return 0;
}


#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
#define pii pair<int,int>
#define pll pair<long long,long long>
#define usi unordered_set<int>
#define usl unordered_set<long long>
#define umii unordered_map<int,int>
#define umsi unordered_map<string,int>
#define umll unordered_map<long long,long long>
#define fi first
#define sec second
#define pub push_back
#define pob pop_back
#define B begin
#define E end
#define mp make_pair
#define vi vector<int>
#define vl vector<long long>
#define vii vector<pii>
#define vll vector<pll>
#define deb(x) cout<<#x<<": "<<x<<"\n"
#define endl '\n'
#define PIE 3.141592653
#define MOD 1000000007
#define f(i,a,b,c) for(ll i=a;i<=b;i+=c)
#define frev(i,n,b,c)  for(ll i=n;i>=b;i-=c)
const ll inf = 1000000000000000000;
using namespace std;

//            < = = = = =    GCD     = = = = = >

ll gcd(ll a, ll b)
{
    if (a < b) gcd(b, a);
    if (b == 0)    return a;
    return gcd(b, a % b);
}

//            < = = = = =    LCM     = = = = = >

ll lcm(ll a, ll b)
{
    ll x = (a / gcd(a, b)) * b;
    return x;
}

//            < = = = = =    power  x^n     = = = = = >

ll power(ll x , ll n , ll m = inf) {
    if (x == 0) {
        return 0;
    }
    if (n == 0) {
        return 1;
    }
    ll ans;
    if (n % 2 == 0) {
        ll smallAns = power(x, n / 2, m);
        ans = (smallAns * smallAns) % m;
    } else {
        ll smallAns = power(x, n - 1, m);
        ans = x;
        ans = (ans * smallAns) % m;
    }
    // for negative values also
    return (ans + m) % m;

}

//            < = = = = =    CHECK FOR PRIME     = = = = = >

bool isprime(int n) {
    if (n == 2) {
        return true;
    }
    else if (n % 2 == 0) {
        return false;
    }
    else {
        for (int i = 3; i * i <= n; i += 2) {
            if (n % i == 0) {
                return false;
            }
        }
        return true;
    }
}

//            < = = = = =    SOLVE    = = = = = >

//  void generate() {
//     memset(div, 0, sizeof div);
//     for (int i = 1; i <= N; i++) {
//         for (int j = i; j <= N; j += i) {
//             divisors[j] += 1;
//         }
//     }
// }

// bool cmp(pll x, pll y){
//     ll dx = min(2*(x.first),x.second)-min(x.first,x.second);
//     ll dy = min(2*(y.first),y.second)-min(y.first,y.second);
//     return dx>dy;
// }

// void rec(int ){
//     if(){

//         return 0;
//     }

//     return ;
// }

int solve() {
    fastio
    string a, b;
    cin >> a >> b;
    ll ans = 0, k = -1;
    int alen = a.length(), blen = b.length();
    ll b0[blen], b1[blen];
    b0[0] = 0;
    b1[0] = 0;
    if (b[0] == '0')b0[0] = 1;
    else b1[0] = 1;
    // cout << b0[0] << " " << b1[0] << endl;
    for (int i = 1; i < blen; ++i)
    {
        if (b[i] == '0') {
            b0[i] = b0[i - 1] + 1;
            b1[i] = b1[i - 1];
        } else {
            b0[i] = b0[i - 1];
            b1[i] = b1[i - 1] + 1;
        }
        // cout << b0[i] << " " << b1[i] << endl;
    }
    if (a[0] == '0') {
        ans += (b1[blen - alen + 0] - 0);
    } else {
        ans += (b0[blen - alen + 0] - 0);
    }
    for (int i = 1; i < alen; ++i)
    {
        if (a[i] == '0') {
            ans += (b1[blen - alen + i] - b1[i - 1]);
        } else {
            ans += (b0[blen - alen + i] - b0[i - 1]);
        }
    }
    cout << ans;
    return 0;
}

//            < = = = = =    MAIN     = = = = = >

int main() {
    fastio

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

    int t = 1;
    //  cin>>t;
    while (t--) {
        solve();
    }

    return 0;
}


#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
#define pii pair<int,int>
#define pll pair<long long,long long>
#define usi unordered_set<int>
#define usl unordered_set<long long>
#define umii unordered_map<int,int>
#define umsi unordered_map<string,int>
#define umll unordered_map<long long,long long>
#define fi first
#define sec second
#define pub push_back
#define pob pop_back
#define B begin
#define E end
#define mp make_pair
#define vi vector<int>
#define vl vector<long long>
#define vii vector<pii>
#define vll vector<pll>
#define deb(x) cout<<#x<<": "<<x<<"\n"
#define endl '\n'
#define PIE 3.141592653
#define MOD 1000000007
#define f(i,a,b,c) for(ll i=a;i<=b;i+=c)
#define frev(i,n,b,c)  for(ll i=n;i>=b;i-=c)
const ll inf = 1000000000000000000;
using namespace std;

//            < = = = = =    GCD     = = = = = >

ll gcd(ll a,ll b)
{
    if(a<b) gcd(b,a);
    if(b==0)    return a;
    return gcd(b,a%b);
}

//            < = = = = =    LCM     = = = = = >

ll lcm(ll a,ll b)
{
    ll x=(a/gcd(a,b))*b;
    return x;
}

//            < = = = = =    power  x^n     = = = = = >

ll power(ll x , ll n , ll m=inf){
    if(x==0){
        return 0;
    }
    if(n==0){
        return 1;
    }
    ll ans;
    if(n%2==0){
        ll smallAns = power(x,n/2,m);
        ans = (smallAns*smallAns)%m;
    } else {
        ll smallAns = power(x,n-1,m);
        ans = x;
        ans = (ans*smallAns)%m;
    }
    // for negative values also
    return (ans+m)%m;

}

//            < = = = = =    CHECK FOR PRIME     = = = = = >

bool isprime(int n){
   if(n==2){
        return true;
    }
    else if(n%2==0){
        return false;
    }
    else{
        for(int i=3;i*i<=n;i+=2){
            if(n%i==0){
                return false;
            }
        }
        return true;
    }
}

//            < = = = = =    SOLVE    = = = = = >

// bool cmp(pll x, pll y){
//     ll dx = min(2*(x.first),x.second)-min(x.first,x.second);
//     ll dy = min(2*(y.first),y.second)-min(y.first,y.second);
//     return dx>dy;
// }

// void rec(int ){
//     if(){

//         return 0;
//     }

//     return ;
// }

int solve() {fastio
    string a,b;
    cin>>a>>b;
    ll ans = 0;
    int al=a.length(),bl=b.length();
    int j=0;
    f(i,0,bl-1,1){
        if(j==al){
            j=0;
            i=i-(al-1);
        } else {
            if(a[j]!=b[i])ans++;
            j++;
        }
    }
    cout<<ans;
    return 0;
}

//            < = = = = =    MAIN     = = = = = >

int main() {fastio

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

    int t=1;
    //  cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
#define pii pair<int,int>
#define pll pair<long long,long long>
#define usi unordered_set<int>
#define usl unordered_set<long long>
#define umii unordered_map<int,int>
#define umsi unordered_map<string,int>
#define umll unordered_map<long long,long long>
#define fi first
#define sec second
#define pub push_back
#define pob pop_back
#define B begin
#define E end
#define mp make_pair
#define vi vector<int>
#define vl vector<long long>
#define vii vector<pii>
#define vll vector<pll>
#define deb(x) cout<<#x<<": "<<x<<"\n"
#define endl '\n'
#define PIE 3.141592653
#define MOD 1000000007
#define f(i,a,b,c) for(ll i=a;i<=b;i+=c)
#define frev(i,n,b,c)  for(ll i=n;i>=b;i-=c)
const ll inf = 1000000000000000000;
using namespace std;

//            < = = = = =    GCD     = = = = = >

ll gcd(ll a,ll b)
{
    if(a<b) gcd(b,a);
    if(b==0)    return a;
    return gcd(b,a%b);
}

//            < = = = = =    LCM     = = = = = >

ll lcm(ll a,ll b)
{
    ll x=(a/gcd(a,b))*b;
    return x;
}

//            < = = = = =    power  x^n     = = = = = >

ll power(ll x , ll n , ll m=inf){
    if(x==0){
        return 0;
    }
    if(n==0){
        return 1;
    }
    ll ans;
    if(n%2==0){
        ll smallAns = power(x,n/2,m);
        ans = (smallAns*smallAns)%m;
    } else {
        ll smallAns = power(x,n-1,m);
        ans = x;
        ans = (ans*smallAns)%m;
    }
    // for negative values also
    return (ans+m)%m;

}

//            < = = = = =    CHECK FOR PRIME     = = = = = >

bool isprime(int n){
   if(n==2){
        return true;
    }
    else if(n%2==0){
        return false;
    }
    else{
        for(int i=3;i*i<=n;i+=2){
            if(n%i==0){
                return false;
            }
        }
        return true;
    }
}

//            < = = = = =    SOLVE    = = = = = >

// bool cmp(pll x, pll y){
//     ll dx = min(2*(x.first),x.second)-min(x.first,x.second);
//     ll dy = min(2*(y.first),y.second)-min(y.first,y.second);
//     return dx>dy;
// }

// void rec(int ){
//     if(){

//         return 0;
//     }

//     return ;
// }

int solve() {fastio
    string a,b;
    cin>>a>>b;
    ll ans = 0;
    int al=a.length(),bl=b.length();
    int j=0;
    f(i,0,bl-1,1){
        if(j==al){
            j=0;
            i=i-(al-1)-1;
        } else {
            if(a[j]!=b[i])ans++;
            j++;
        }
    }
    cout<<ans;
    return 0;
}

//            < = = = = =    MAIN     = = = = = >

int main() {fastio

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

    int t=1;
    //  cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
#define pii pair<int,int>
#define pll pair<long long,long long>
#define usi unordered_set<int>
#define usl unordered_set<long long>
#define umii unordered_map<int,int>
#define umsi unordered_map<string,int>
#define umll unordered_map<long long,long long>
#define fi first
#define sec second
#define pub push_back
#define pob pop_back
#define B begin
#define E end
#define mp make_pair
#define vi vector<int>
#define vl vector<long long>
#define vii vector<pii>
#define vll vector<pll>
#define deb(x) cout<<#x<<": "<<x<<"\n"
#define endl '\n'
#define PIE 3.141592653
#define MOD 1000000007
#define f(i,a,b,c) for(ll i=a;i<=b;i+=c)
#define frev(i,n,b,c)  for(ll i=n;i>=b;i-=c)
const ll inf = 1000000000000000000;
using namespace std;

//            < = = = = =    GCD     = = = = = >

ll gcd(ll a,ll b)
{
    if(a<b) gcd(b,a);
    if(b==0)    return a;
    return gcd(b,a%b);
}

//            < = = = = =    LCM     = = = = = >

ll lcm(ll a,ll b)
{
    ll x=(a/gcd(a,b))*b;
    return x;
}

//            < = = = = =    power  x^n     = = = = = >

ll power(ll x , ll n , ll m=inf){
    if(x==0){
        return 0;
    }
    if(n==0){
        return 1;
    }
    ll ans;
    if(n%2==0){
        ll smallAns = power(x,n/2,m);
        ans = (smallAns*smallAns)%m;
    } else {
        ll smallAns = power(x,n-1,m);
        ans = x;
        ans = (ans*smallAns)%m;
    }
    // for negative values also
    return (ans+m)%m;

}

//            < = = = = =    CHECK FOR PRIME     = = = = = >

bool isprime(int n){
   if(n==2){
        return true;
    }
    else if(n%2==0){
        return false;
    }
    else{
        for(int i=3;i*i<=n;i+=2){
            if(n%i==0){
                return false;
            }
        }
        return true;
    }
}

//            < = = = = =    SOLVE    = = = = = >

// bool cmp(pll x, pll y){
//     ll dx = min(2*(x.first),x.second)-min(x.first,x.second);
//     ll dy = min(2*(y.first),y.second)-min(y.first,y.second);
//     return dx>dy;
// }

// void rec(int ){
//     if(){

//         return 0;
//     }

//     return ;
// }

int solve() {fastio
    string a,b;
    cin>>a>>b;
    ll ans = 0;
    int al=a.length(),bl=b.length();
    int j=0;
    f(i,0,bl-1,1){
        if(j==al){
            j=0;
            // if(i==bl-1)break;
            i=i-al;
        } else {
            ans = ans + (a[j]^b[i]);
            j++;
        }
    }
    cout<<ans;
    return 0;
}

//            < = = = = =    MAIN     = = = = = >

int main() {fastio

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

    int t=1;
    //  cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
#define pii pair<int,int>
#define pll pair<long long,long long>
#define usi unordered_set<int>
#define usl unordered_set<long long>
#define umii unordered_map<int,int>
#define umsi unordered_map<string,int>
#define umll unordered_map<long long,long long>
#define fi first
#define sec second
#define pub push_back
#define pob pop_back
#define B begin
#define E end
#define mp make_pair
#define vi vector<int>
#define vl vector<long long>
#define vii vector<pii>
#define vll vector<pll>
#define deb(x) cout<<#x<<": "<<x<<"\n"
#define endl '\n'
#define PIE 3.141592653
#define MOD 1000000007
#define f(i,a,b,c) for(ll i=a;i<=b;i+=c)
#define frev(i,n,b,c)  for(ll i=n;i>=b;i-=c)
const ll inf = 1000000000000000000;
using namespace std;

//            < = = = = =    GCD     = = = = = >

ll gcd(ll a,ll b)
{
    if(a<b) gcd(b,a);
    if(b==0)    return a;
    return gcd(b,a%b);
}

//            < = = = = =    LCM     = = = = = >

ll lcm(ll a,ll b)
{
    ll x=(a/gcd(a,b))*b;
    return x;
}

//            < = = = = =    power  x^n     = = = = = >

ll power(ll x , ll n , ll m=inf){
    if(x==0){
        return 0;
    }
    if(n==0){
        return 1;
    }
    ll ans;
    if(n%2==0){
        ll smallAns = power(x,n/2,m);
        ans = (smallAns*smallAns)%m;
    } else {
        ll smallAns = power(x,n-1,m);
        ans = x;
        ans = (ans*smallAns)%m;
    }
    // for negative values also
    return (ans+m)%m;

}

//            < = = = = =    CHECK FOR PRIME     = = = = = >

bool isprime(int n){
   if(n==2){
        return true;
    }
    else if(n%2==0){
        return false;
    }
    else{
        for(int i=3;i*i<=n;i+=2){
            if(n%i==0){
                return false;
            }
        }
        return true;
    }
}

//            < = = = = =    SOLVE    = = = = = >

// bool cmp(pll x, pll y){
//     ll dx = min(2*(x.first),x.second)-min(x.first,x.second);
//     ll dy = min(2*(y.first),y.second)-min(y.first,y.second);
//     return dx>dy;
// }

// void rec(int ){
//     if(){

//         return 0;
//     }

//     return ;
// }

int solve() {fastio
    string a,b;
    cin>>a>>b;
    ll ans = 0;
    int al=a.length(),bl=b.length();
    int j=0;
    f(i,0,bl-1,1){
        if(j==al){
            j=0;
            if(i==bl-1)break;
            i=i-al;
        } else {
            if(a[j]!=b[i])ans++;
            j++;
        }
    }
    cout<<ans;
    return 0;
}

//            < = = = = =    MAIN     = = = = = >

int main() {fastio

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

    int t=1;
    //  cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<list>
#include <algorithm>
#include<vector>
#include<set>
#include <cctype>
#include <cstring>
#include <cstdio>
#include<queue>
#include<stack>
#include<bitset>
#include<time.h>
#include<fstream>
/******************************************************/

using namespace std;

/********************define***************************/
#define ll 				long long
#define ld				long double
#define all(v)				((v).begin()), ((v).end())
#define for_(vec) 		for(int i=0;i<(int)vec.size();i++)
#define lp(j,n)		for(int i=j;i<(int)(n);i++)
#define clr(arr,x)  memset(arr,x,sizeof(arr))
#define fillstl(arr,X)    fill(arr.begin(),arr.end(),X)
#define pb         push_back
#define mp	   		make_pair
#define print_vector(X)  for(int i=0;i<X.size();i++)
/********************************************************/
typedef vector<int> vi;
typedef vector<pair<int, int>> vii;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
/***********************function************************/

void fast(){ios_base::sync_with_stdio(NULL);cin.tie(0); cout.tie(0);}
void online_judge(){freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);}
const int flag_max=0x3f3f3f3f;
const ll OO=1e9 ;
const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}

 ll gcd(ll a, ll b) {return !b ? a : gcd(b, a % b);}
 ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b;}

/***********************main_problem****************************/

double H_N(int n){return n==1.0?1.0:(1.0/n)+H_N(n-1);}

/**************************Bisho_O*****************************************/
int main() {

fast();
string s1,s2;

cin>>s1>>s2;
int ans=0;
for(int i=0;i<s1.size();i++){

int X=s1.size()-i;
for(int j=i;j<=((s2.size()-X));j++){

s2[j]==s1[i]?ans:ans++;

}

}
cout<<ans;
return 0;
}


#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<list>
#include <algorithm>
#include<vector>
#include<set>
#include <cctype>
#include <cstring>
#include <cstdio>
#include<queue>
#include<stack>
#include<bitset>
#include<time.h>
#include<fstream>
/******************************************************/

using namespace std;

/********************define***************************/
#define ll 				long long
#define ld				long double
#define all(v)				((v).begin()), ((v).end())
#define for_(vec) 		for(int i=0;i<(int)vec.size();i++)
#define lp(j,n)		for(int i=j;i<(int)(n);i++)
#define clr(arr,x)  memset(arr,x,sizeof(arr))
#define fillstl(arr,X)    fill(arr.begin(),arr.end(),X)
#define pb         push_back
#define mp	   		make_pair
#define print_vector(X)  for(int i=0;i<X.size();i++)
/********************************************************/
typedef vector<int> vi;
typedef vector<pair<int, int>> vii;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
/***********************function************************/

void fast(){ios_base::sync_with_stdio(NULL);cin.tie(0); cout.tie(0);}
void online_judge(){freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);}
const int flag_max=0x3f3f3f3f;
const ll OO=1e9 ;
const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}

 ll gcd(ll a, ll b) {return !b ? a : gcd(b, a % b);}
 ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b;}

/***********************main_problem****************************/

double H_N(int n){return n==1.0?1.0:(1.0/n)+H_N(n-1);}

int dp1[2000001],dp0[2000001];
/**************************Bisho_O*****************************************/
int main() {

fast();

string s1,s2;
ll ans=0;
cin>>s1>>s2;

int sz1=s1.size(),sz2=s2.size();

for(int i=0;i<s2.size();i++){

s2[i]=='0'?dp0[i]++:dp1[i]++;

dp0[i] += dp0[i-1];
dp1[i] += dp1[i-1];

}

int dif=sz2-sz1;

for(int i=0;i<s1.size();i++){

if(s1[i]=='0'){
    ans+=dp1[i+dif]-dp1[i-1];

}
else{
    ans+=dp0[i+dif]-dp0[i-1];
}

}

cout<<ans;
return 0;
}


#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<list>
#include <algorithm>
#include<vector>
#include<set>
#include <cctype>
#include <cstring>
#include <cstdio>
#include<queue>
#include<stack>
#include<bitset>
#include<time.h>
#include<fstream>
/******************************************************/

using namespace std;

/********************define***************************/
#define ll 				long long
#define ld				long double
#define all(v)				((v).begin()), ((v).end())
#define for_(vec) 		for(int i=0;i<(int)vec.size();i++)
#define lp(j,n)		for(int i=j;i<(int)(n);i++)
#define clr(arr,x)  memset(arr,x,sizeof(arr))
#define fillstl(arr,X)    fill(arr.begin(),arr.end(),X)
#define pb         push_back
#define mp	   		make_pair
#define print_vector(X)  for(int i=0;i<X.size();i++)
/********************************************************/
typedef vector<int> vi;
typedef vector<pair<int, int>> vii;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
/***********************function************************/

void fast(){ios_base::sync_with_stdio(NULL);cin.tie(0); cout.tie(0);}
void online_judge(){freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);}
const int flag_max=0x3f3f3f3f;
const ll OO=1e9 ;
const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}

 ll gcd(ll a, ll b) {return !b ? a : gcd(b, a % b);}
 ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b;}

/***********************main_problem****************************/

double H_N(int n){return n==1.0?1.0:(1.0/n)+H_N(n-1);}

/**************************Bisho_O*****************************************/
int main() {

fast();

map<string,int>sq;

map<string,int>::iterator it;

string s1,s2;
cin>>s1>>s2;

int Q=s1.size();
for(int i=0;i<s2.size();i++){
string X=s2.substr(i,Q);

if(X.size()==s1.size()){sq[X]++;}

}

int ans=0;

for(it=sq.begin();it!=sq.end();it++){

string S=it->first;
int flag=0;
for(int i=0;i<S.size();i++){ S[i]==s1[i]?flag:flag++;}
ans+=flag*it->second;

}
cout<<ans;
return 0;
}


#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<list>
#include <algorithm>
#include<vector>
#include<set>
#include <cctype>
#include <cstring>
#include <cstdio>
#include<queue>
#include<stack>
#include<bitset>
#include<time.h>
#include<fstream>
/******************************************************/

using namespace std;

/********************define***************************/
#define ll 				long long
#define ld				long double
#define all(v)				((v).begin()), ((v).end())
#define for_(vec) 		for(int i=0;i<(int)vec.size();i++)
#define lp(j,n)		for(int i=j;i<(int)(n);i++)
#define clr(arr,x)  memset(arr,x,sizeof(arr))
#define fillstl(arr,X)    fill(arr.begin(),arr.end(),X)
#define pb         push_back
#define mp	   		make_pair
#define print_vector(X)  for(int i=0;i<X.size();i++)
/********************************************************/
typedef vector<int> vi;
typedef vector<pair<int, int>> vii;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
/***********************function************************/

void fast(){ios_base::sync_with_stdio(NULL);cin.tie(0); cout.tie(0);}
void online_judge(){freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);}
const int flag_max=0x3f3f3f3f;
const ll OO=1e9 ;
const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}

 ll gcd(ll a, ll b) {return !b ? a : gcd(b, a % b);}
 ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b;}

/***********************main_problem****************************/

double H_N(int n){return n==1.0?1.0:(1.0/n)+H_N(n-1);}

int dp1[2000001],dp0[2000001];
/**************************Bisho_O*****************************************/
int main() {

fast();

string s1,s2;
ll ans=0;
cin>>s1>>s2;

int sz1=s1.size(),sz2=s2.size();

for(int i=0;i<s2.size();i++){

s2[i]=='0'?dp0[i]++:dp1[i]++;

if(i>0){
            dp0[i] += dp0[i-1];
            dp1[i] += dp1[i-1];
        }
}

int dif=sz2-sz1;

for(int i=0;i<s1.size();i++){

if(s1[i]=='0'){
    ans+=dp1[i+dif]-dp1[i-1];

}
else{
    ans+=dp0[i+dif]-dp0[i-1];
}

}

cout<<ans;
return 0;
}


#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<list>
#include <algorithm>
#include<vector>
#include<set>
#include <cctype>
#include <cstring>
#include <cstdio>
#include<queue>
#include<stack>
#include<bitset>
#include<time.h>
#include<fstream>
/******************************************************/

using namespace std;

/********************define***************************/
#define ll 				long long
#define ld				long double
#define all(v)				((v).begin()), ((v).end())
#define for_(vec) 		for(int i=0;i<(int)vec.size();i++)
#define lp(j,n)		for(int i=j;i<(int)(n);i++)
#define clr(arr,x)  memset(arr,x,sizeof(arr))
#define fillstl(arr,X)    fill(arr.begin(),arr.end(),X)
#define pb         push_back
#define mp	   		make_pair
#define print_vector(X)  for(int i=0;i<X.size();i++)
/********************************************************/

/***********************function************************/

void fast(){ios_base::sync_with_stdio(NULL),cin.tie(0),cout.tie(0);}
void online_judge(){freopen("input.txt", "r", stdin);}
const int flag_max=0x3f3f3f3f;
const ll OO=1e9+7;
const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}

/***********************main_problem****************************/

ll ANS(string a,string b){
ll ans=0;
for(int i=0;i<a.size();i++){

    ans+=abs((a[i]-'0')-(b[i]-'0'));

}
return ans;

}

/*******************************************************************/
int main() {
    /*
    fast();
*/

string a,b;
cin>>a>>b;
ll ans=0;
for(int i=0;i<b.size();i++){
    string flag="";
    for(int j=i;j<(i+a.size());j++){if(j<b.size()){flag+=b[j];}  if(flag.size()==a.size()){ans+=ANS(flag,a);}        }

}
cout<<ans;

  return 0;
}


#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<list>
#include <algorithm>
#include<vector>
#include<set>
#include <cctype>
#include <cstring>
#include <cstdio>
#include<queue>
#include<stack>
#include<bitset>
#include<time.h>
#include<fstream>
/******************************************************/

using namespace std;

/********************define***************************/
#define ll 				long long
#define ld				long double
#define all(v)				((v).begin()), ((v).end())
#define for_(vec) 		for(int i=0;i<(int)vec.size();i++)
#define lp(j,n)		for(int i=j;i<(int)(n);i++)
#define clr(arr,x)  memset(arr,x,sizeof(arr))
#define fillstl(arr,X)    fill(arr.begin(),arr.end(),X)
#define pb         push_back
#define mp	   		make_pair
#define print_vector(X)  for(int i=0;i<X.size();i++)
/********************************************************/
typedef vector<int> vi;
typedef vector<pair<int, int>> vii;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
/***********************function************************/

void fast(){ios_base::sync_with_stdio(NULL);cin.tie(0); cout.tie(0);}
void online_judge(){freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);}
const int flag_max=0x3f3f3f3f;
const ll OO=1e9 ;
const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}

 ll gcd(ll a, ll b) {return !b ? a : gcd(b, a % b);}
 ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b;}

/***********************main_problem****************************/

double H_N(int n){return n==1.0?1.0:(1.0/n)+H_N(n-1);}

ll dp1[2000001],dp0[2000001];
/**************************Bisho_O*****************************************/
int main() {

fast();

string s1,s2;
ll ans=0;
cin>>s1>>s2;

int sz1=s1.size(),sz2=s2.size();

for(int i=0;i<s2.size();i++){

s2[i]=='0'?dp0[i]++:dp1[i]++;

if(i>0){
            dp0[i] += dp0[i-1];
            dp1[i] += dp1[i-1];
        }
}

ll dif=sz2-sz1;

for(int i=0;i<s1.size();i++){

if(s1[i]=='0'){
    ans+=dp1[i+dif]-dp1[i-1];

}
else{
    ans+=dp0[i+dif]-dp0[i-1];
}

}

cout<<ans;
return 0;
}


#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<list>
#include <algorithm>
#include<vector>
#include<set>
#include <cctype>
#include <cstring>
#include <cstdio>
#include<queue>
#include<stack>
#include<bitset>
#include<time.h>
#include<fstream>
/******************************************************/

using namespace std;

/********************define***************************/
#define ll 				long long
#define ld				long double
#define all(v)				((v).begin()), ((v).end())
#define for_(vec) 		for(int i=0;i<(int)vec.size();i++)
#define lp(j,n)		for(int i=j;i<(int)(n);i++)
#define clr(arr,x)  memset(arr,x,sizeof(arr))
#define fillstl(arr,X)    fill(arr.begin(),arr.end(),X)
#define pb         push_back
#define mp	   		make_pair
#define print_vector(X)  for(int i=0;i<X.size();i++)
/********************************************************/
typedef vector<int> vi;
typedef vector<pair<int, int>> vii;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
/***********************function************************/

void fast(){ios_base::sync_with_stdio(NULL);cin.tie(0); cout.tie(0);}
void online_judge(){freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);}
const int flag_max=0x3f3f3f3f;
const ll OO=1e9 ;
const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}

 ll gcd(ll a, ll b) {return !b ? a : gcd(b, a % b);}
 ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b;}

/***********************main_problem****************************/

double H_N(int n){return n==1.0?1.0:(1.0/n)+H_N(n-1);}

int dp1[2000001],dp0[2000001];
/**************************Bisho_O*****************************************/
int main() {

fast();

string s1,s2;
int ans=0;
cin>>s1>>s2;

int sz1=s1.size(),sz2=s2.size();

for(int i=0;i<s2.size();i++){

s2[i]=='0'?dp0[i]++:dp1[i]++;

i>0?dp0[i]+=dp0[i-1],dp1[i]+=dp1[i-1]:NULL;

}

int dif=sz2-sz1;

for(int i=0;i<s1.size();i++){

if(s1[i]=='0'){
    ans+=dp1[i+dif]-dp1[i-1];

}
else{
    ans+=dp0[i+dif]-dp0[i-1];
}

}

cout<<ans;
return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007

typedef long long ll;

int main(){
    string a, b;
    cin >> a >> b;
    int n = a.size(), m = b.size();
    vector<ll> pre(n, 0), suf(n, 0), dis(m, 0);
    if( a[0] == '1' )
        pre[0] = 1;
    for(int i = 1; i < n; i++)
        if( a[i] == '1' )
            pre[i] = pre[i-1] + 1;
        else
            pre[i] = pre[i-1];
    if( a[n-1] == '1' )
        suf[n-1] = 1;
    for(int i = n-2; i >= 0; i--)
        if( a[i] == '1' )
            suf[i] = suf[i+1]+1;
        else
            suf[i] = suf[i+1];

    if( m < 2*n ){
        int tms = m - n;
        for(int i = 0; i < tms; i++)
            if( b[i] == '1' )
                dis[i] = (i+1) - pre[i];
            else
                dis[i] = pre[i];
        int en = m-1;
        for(int i = 0; i < tms; i++, en--)
            if( b[en] == '1' )
                dis[en] = (i+1) - suf[n-1-i];
            else
                dis[en] = suf[n-1-i];
        //cout << " en " << en << endl;
        for(int st = tms; st <= en; st++){
            if( b[st] == '1' )
                dis[st] = (tms+1) - (pre[st] - ( st-tms-1 >= 0 ? pre[st-tms-1] : 0));
            else
                dis[st] = (pre[st] - ( st-tms-1 >= 0 ? pre[st-tms-1] : 0 ));
            //cout << st << " ## " << dis[st] << endl;
        }
        //cout << " -- " << tms << endl;
        ll tot = 0;
        for(int i = 0; i < m; i++)
            tot = ( tot + dis[i] )%MOD;

        cout << tot << endl;
    }else{
        int st = 0, en = m-1;
        for(; st < n; st++)
            if( b[st] == '1' )
                dis[st] = (st+1)-pre[st];
            else
                dis[st] = pre[st];
        for(int i = 0; i < n; i++, en--)
            if( b[en] == '1' )
                dis[en] = (i+1)-suf[n-1-i];
            else
                dis[en] = suf[n-1-i];
        for(; st <= en; st++)
            if( b[st] == '1' )
                dis[st] = n-pre[n-1];
            else
                dis[st] = pre[n-1];
        ll tot = 0;
        for(int i = 0; i < m; i++)
            tot = ( tot + dis[i] )%MOD;

        cout << tot << endl;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main(){

    string a, b;
    cin >> a >> b;
    int n = a.size(), m = b.size();
    vector<ll> preone(m+1, 0), prezero(m+1, 0);
    if( b[0] == '1' )
        preone[1] = 1;
    else
        prezero[1] = 1;

    for(int i = 1; i < m; i++)
        if( b[i] == '1' )
            preone[i+1] = preone[i]+1, prezero[i+1] = prezero[i];
        else
            preone[i+1] = preone[i], prezero[i+1] = prezero[i]+1;

    ll tot = 0;
    for(int i = 0, j = m - n+1; i < n; i++, j++){
        if( a[i] == '1' ){
            tot = ( tot + (prezero[j] - prezero[i]) );
        }else{
            tot = ( tot + (preone[j] - preone[i]) );
        }
    }

    cout << tot << endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007

typedef long long ll;

int main(){
    string a, b;
    cin >> a >> b;
    int n = a.size(), m = b.size();
    vector<ll> pre(n, 0), suf(n, 0), dis(m, 0);
    if( a[0] == '1' )
        pre[0] = 1;
    for(int i = 1; i < n; i++)
        if( a[i] == '1' )
            pre[i] = pre[i-1] + 1;
        else
            pre[i] = pre[i-1];
    if( a[n-1] == '1' )
        suf[n-1] = 1;
    for(int i = n-2; i >= 0; i--)
        if( a[i] == '1' )
            suf[i] = suf[i+1]+1;
        else
            suf[i] = suf[i+1];

    if( m < 2*n ){
        int tms = m - n;
        for(int i = 0; i < tms; i++)
            if( b[i] == '1' )
                dis[i] = (i+1) - pre[i];
            else
                dis[i] = pre[i];
        int en = m-1;
        for(int i = 0; i < tms; i++, en--)
            if( b[en] == '1' )
                dis[en] = (i+1) - suf[n-1-i];
            else
                dis[en] = suf[n-1-i];
        //cout << " en " << en << endl;
        for(int st = tms; st <= en; st++){
            if( dis[st] == '1' )
                dis[st] = (tms+1) - (pre[st] - ( st-tms-1 >= 0 ? pre[st-tms-1] : 0));
            else
                dis[st] = (pre[st] - ( st-tms-1 >= 0 ? pre[st-tms-1] : 0 ));
            //cout << st << " ## " << dis[st] << endl;
        }
        //cout << " -- " << tms << endl;
        ll tot = 0;
        for(int i = 0; i < m; i++)
            tot = ( tot + dis[i] )%MOD;

        cout << tot << endl;
    }else{
        int st = 0, en = m-1;
        for(; st < n; st++)
            if( b[st] == '1' )
                dis[st] = (st+1)-pre[st];
            else
                dis[st] = pre[st];
        for(int i = 0; i < n; i++, en--)
            if( b[en] == '1' )
                dis[en] = (i+1)-suf[n-1-i];
            else
                dis[en] = suf[n-1-i];
        for(; st <= en; st++)
            if( dis[st] == '1' )
                dis[st] = n-pre[n-1];
            else
                dis[st] = pre[n-1];
        ll tot = 0;
        for(int i = 0; i < m; i++)
            tot = ( tot + dis[i] )%MOD;

        cout << tot << endl;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main(){

    string a, b;
    cin >> a >> b;
    int n = a.size(), m = b.size();
    vector<ll> preone(m+1, 0), prezero(m+1, 0);
    if( b[0] == '1' )
        preone[1] = 1;
    else
        prezero[1] = 1;

    for(int i = 1; i < m; i++)
        if( b[i] == '1' )
            preone[i+1] = preone[i]+1, prezero[i+1] = prezero[i];
        else
            preone[i+1] = preone[i], prezero[i+1] = prezero[i]+1;

    ll tot = 0;
    for(int i = 0, j = m - n+1; i < n; i++, j++){
        if( a[i] == '1' ){
            tot = ( tot + (prezero[j] - prezero[i])%MOD )%MOD;
        }else{
            tot = ( tot + (preone[j] - preone[i])%MOD )%MOD;
        }
    }

    tot = tot%MOD;
    cout << ((tot+MOD)%MOD) << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int f[1001],t[1001];
int main()
{
    int n,m;
    string s1,s2;
    cin>>s1>>s2;
    n = s1.size(),m = s2.size();
    bitset<200001> bit1(s1),bit2(s2);
    long long ans = 0;
    for(int i =0;i<m-n+1;i++)
    {
        bitset<200001> bit2(s2,i,n);
        bit2 ^= bit1;
        ans += bit2.count();
    }
    cout<<ans<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int f[1001],t[1001];
int main()
{
    int n,m;
    string s1,s2;
    cin>>s1>>s2;
    n = s1.size(),m = s2.size();
    bitset<200001> bit1(s1);
    int ans = 0;
    for(int i =0;i<m-n+1;i++)
    {
        bitset<200001> bit2(s2,i,n);
        bit2 ^= bit1;
        ans += bit2.count();
    }
    cout<<ans<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int f[1001],t[1001];
int main()
{
    int n,m;
    string s1,s2;
    cin>>s1>>s2;
    n = s1.size(),m = s2.size();
    bitset<200001> bit1(s1),bit2(s2);
    long long ans = 0;
    for(int i = 0;i<200000;i++)
        cout<<0;
    for(int i =0;i<m-n+1;i++)
    {
        bitset<200001> bit2(s2,i,n);
        bit2 ^= bit1;
        ans += bit2.count();
    }
    cout<<ans<<endl;
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
clock_t T;
#define ctime cerr << "Time : " << double(clock() - T) / CLOCKS_PER_SEC << endl
#define all(v) ((v).begin()), ((v).end())
#define sz(v) v.size()
#define endl "\n"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
constexpr auto EPS = 1e-9;
const int mod = (int)1e9 + 7;
const double pi = acos(-1);
int dx[] = { 0, 0, 1, -1, 1, 1, -1, -1 };
int dy[] = { 1, -1, 0, 0, 1, -1, 1, -1 };
ll gcd(ll a, ll b) { return (a) ? gcd(b % a, a) : b; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
void GOAT()
{
	std::ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);// freopen("out.txt", "w", stdout);
#endif
}
int main()
{
	GOAT();
	string s, t;
	cin >> s >> t;
	vector<int>one(sz(t)),zero(sz(t));
	one[0] = t[0] - '0';
	zero[0] = !one[0];
	for (int i = 1; i < sz(t); i++)
		one[i] = one[i - 1] + t[i]=='1',zero[i]=zero[i-1]+(t[i]=='0');
	ll ans = 0;
	if (s[0] == '0')ans += one[sz(t) - sz(s)];
	else ans += zero[sz(t) - sz(s)];
	for (int i = 1; i < sz(s); i++)
	{
		if (s[i] == '0')ans += one[i + sz(t) - sz(s)] - one[i - 1];
		else ans += (zero[i + sz(t) - sz(s)] - zero[i - 1]);
	}
	cout << ans << endl;

}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
clock_t T;
#define ctime cerr << "Time : " << double(clock() - T) / CLOCKS_PER_SEC << endl
#define all(v) ((v).begin()), ((v).end())
#define sz(v) v.size()
#define endl "\n"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
constexpr auto EPS = 1e-9;
const int mod = (int)1e9 + 7;
const double pi = acos(-1);
int dx[] = { 0, 0, 1, -1, 1, 1, -1, -1 };
int dy[] = { 1, -1, 0, 0, 1, -1, 1, -1 };
ll gcd(ll a, ll b) { return (a) ? gcd(b % a, a) : b; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
void GOAT()
{
	std::ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);// freopen("out.txt", "w", stdout);
#endif
}
int main()
{
	GOAT();
	string s, t;
	cin >> s >> t;
	int l = 0, r = sz(s);
	int cnt = 0, sum = 0,tosum=0;
	for (int i = 0; i < sz(s); i++)
	sum += abs(s[i] -t[i]),cnt+=t[i]-'0';
	tosum = sum;
	while (r<sz(t))
	{
		cnt-= t[l++] - '0';
		cnt+= t[r++] - '0';
		//cout << l << "  " << r <<"  "<<cnt<< endl;
		tosum += abs(sum - cnt);
	}
	cout << tosum << endl;

}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
clock_t T;
#define ctime cerr << "Time : " << double(clock() - T) / CLOCKS_PER_SEC << endl
#define all(v) ((v).begin()), ((v).end())
#define sz(v) v.size()
#define endl "\n"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
constexpr auto EPS = 1e-9;
const int mod = (int)1e9 + 7;
const double pi = acos(-1);
int dx[] = { 0, 0, 1, -1, 1, 1, -1, -1 };
int dy[] = { 1, -1, 0, 0, 1, -1, 1, -1 };
ll gcd(ll a, ll b) { return (a) ? gcd(b % a, a) : b; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
void GOAT()
{
	std::ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);// freopen("out.txt", "w", stdout);
#endif
}
int main()
{
	GOAT();
	string s, t;
	cin >> s >> t;
	vector<int>one(sz(t));
	one[0] = t[0] - '0';
	for(int i=1;i<sz(t);i++)
		one[i] = one[i-1]+ t[i] - '0';
	ll ans = 0;
	for (int i = 0; i < sz(s); i++)
	{
		if (s[i] == '0')ans += one[i+ sz(t) - sz(s)];
		else ans+= (sz(t)-sz(s)+1)-(one[sz(t) - sz(s) + i]);
		if (i)ans -= one[i - 1];
	}
	cout << ans << endl;

}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
clock_t T;
#define ctime cerr << "Time : " << double(clock() - T) / CLOCKS_PER_SEC << endl
#define all(v) ((v).begin()), ((v).end())
#define sz(v) v.size()
#define endl "\n"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
constexpr auto EPS = 1e-9;
const int mod = (int)1e9 + 7;
const double pi = acos(-1);
int dx[] = { 0, 0, 1, -1, 1, 1, -1, -1 };
int dy[] = { 1, -1, 0, 0, 1, -1, 1, -1 };
ll gcd(ll a, ll b) { return (a) ? gcd(b % a, a) : b; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
void GOAT()
{
	std::ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);// freopen("out.txt", "w", stdout);
#endif
}
int main()
{
	GOAT();
	string s, t;
	cin >> s >> t;
	int l = 0, r = sz(s);
	int cnt = 0, sum = 0,tosum=0;
	for (int i = 0; i < sz(s); i++)
	sum += abs(s[i] -t[i]),cnt+=s[i]-'0';
	tosum = sum;
	while (r<sz(t))
	{
		cnt-= t[l++] - '0';
		cnt+= t[r++] - '0';
		//cout << l << "  " << r <<"  "<<cnt<< endl;
		tosum += abs(sum - cnt);
	}
	cout << tosum << endl;

}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
clock_t T;
#define ctime cerr << "Time : " << double(clock() - T) / CLOCKS_PER_SEC << endl
#define all(v) ((v).begin()), ((v).end())
#define sz(v) v.size()
#define endl "\n"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
constexpr auto EPS = 1e-9;
const int mod = (int)1e9 + 7;
const double pi = acos(-1);
int dx[] = { 0, 0, 1, -1, 1, 1, -1, -1 };
int dy[] = { 1, -1, 0, 0, 1, -1, 1, -1 };
ll gcd(ll a, ll b) { return (a) ? gcd(b % a, a) : b; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
void GOAT()
{
	std::ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);// freopen("out.txt", "w", stdout);
#endif
}
int main()
{
	GOAT();
	string s, t;
	cin >> s >> t;
	vector<int>one(sz(t)),zero(sz(t));
	one[0] = t[0] - '0';
	zero[0] = !one[0];
	for (int i = 1; i < sz(t); i++)
		one[i] = one[i - 1] + (t[i]=='1'),zero[i]=zero[i-1]+(t[i]=='0');
	ll ans = 0;
	if (s[0] == '0')ans += one[sz(t) - sz(s)];
	else ans += zero[sz(t) - sz(s)];
	for (int i = 1; i < sz(s); i++)
	{
		if (s[i] == '0')ans += one[i + sz(t) - sz(s)] - one[i - 1];
		else ans +=zero[i + sz(t) - sz(s)] - zero[i - 1];
	}
	cout << ans << endl;

}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
clock_t T;
#define ctime cerr << "Time : " << double(clock() - T) / CLOCKS_PER_SEC << endl
#define all(v) ((v).begin()), ((v).end())
#define sz(v) v.size()
#define endl "\n"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
constexpr auto EPS = 1e-9;
const int mod = (int)1e9 + 7;
const double pi = acos(-1);
int dx[] = { 0, 0, 1, -1, 1, 1, -1, -1 };
int dy[] = { 1, -1, 0, 0, 1, -1, 1, -1 };
ll gcd(ll a, ll b) { return (a) ? gcd(b % a, a) : b; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
void GOAT()
{
	std::ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);// freopen("out.txt", "w", stdout);
#endif
}
int main()
{
	GOAT();
	string s, t;
	cin >> s >> t;
	vector<int>one(sz(t));
	one[0] = t[0] - '0';
	for(int i=1;i<sz(t);i++)
		one[i] = one[i-1]+ t[i] - '0';
	ll ans = 0;
	if (s[0] == '0')ans += one[ sz(t) - sz(s)];
	else ans += (sz(t) - sz(s) + 1) - (one[sz(t) - sz(s)]);
	for (int i = 1; i < sz(s); i++)
	{
		if (s[i] == '0')ans += one[i+ sz(t) - sz(s)]-one[i - 1];
		else ans+= (sz(t)-sz(s)+1)-(one[i+sz(t) - sz(s)]- one[i - 1]);
	}
	cout << ans << endl;

}


#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WAENINGS
#define Mapogo ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);
typedef long long ll;
#define sortt(a) sort(a.begin(),a.end())
#define r(i,x,n) (int i=x;i<n;i++)
#define i(n) (int i=0;i<n;i++)
#define yes cout<<"yes\n"
#define no cout<<"no\n"
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
#define endl "\n"
#define Pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
using namespace std;
//============== GCD ==================//
//long long gcd(long long a, long long b)
//{
//	if (b == 0)
//		return a;
//	return gcd(b, a % b);
//}
//============== LCM ================       ==//
//int lcm(int a, int b)
//{
//    return (a * b) / gcd(a, b);
//}
//============ Plaindrome =============//
//bool plaindrome(string s) {
//	for (int i = 0, j = s.size() - 1; i < s.size() / 2; i++, j--) {
//		if (s[i] != s[j])
//			return false;
//	}
//	return true;
//}
//============ in/out file ============//
//void file() {
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
//}
//============== Prime ===============//
//bool prime(ll n) {
//	if (n == 1)return false;
//	if (n == 2)return true;
//	for (ll i = 2; i*i <= n; i++)
//        if (n % i == 0) return false;
//	return true;
//}
//bool oneway(ll x1, ll y1, ll x2, ll y2, ll x3, ll y3) {
//	ll a = x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2);
//	if (a == 0)return true;
//	return false;
//}
int main()
{
	Mapogo;
	string x, b;
	cin >> x >> b;
	vector <vector <int>> v(2, vector <int>(b.size() + 1));
	/*if (b[0] == '0')v[0][0] = 1;
	else v[1][0] = 1;*/
	for r(i, 1, b.size() + 1) {
		v[0][i] += v[0][i - 1] + (b[i - 1] == '0');
		v[1][i] += v[1][i - 1] + (b[i - 1] == '1');
	}
	ll ans = 0;
	for i(x.size()) {
		if (x[i] == '0')
			ans += v[1][b.size() - x.size() + i + 1] - v[1][i];
		else ans += v[0][b.size() - x.size() + i + 1] - v[0][i];
	}
	cout << ans;
	/*for i(b.size() + 1)cout << v[0][i] << " " << v[1][i] << endl;*/
	return 0;
}


#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WAENINGS
#define Mapogo ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);
typedef long long ll;
#define sortt(a) sort(a.begin(),a.end())
#define r(i,x,n) (int i=x;i<n;i++)
#define i(n) (int i=0;i<n;i++)
#define yes cout<<"yes\n"
#define no cout<<"no\n"
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
#define endl "\n"
#define Pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
using namespace std;
//============== GCD ==================//
//long long gcd(long long a, long long b)
//{
//	if (b == 0)
//		return a;
//	return gcd(b, a % b);
//}
//============== LCM ================       ==//
//int lcm(int a, int b)
//{
//    return (a * b) / gcd(a, b);
//}
//============ Plaindrome =============//
//bool plaindrome(string s) {
//	for (int i = 0, j = s.size() - 1; i < s.size() / 2; i++, j--) {
//		if (s[i] != s[j])
//			return false;
//	}
//	return true;
//}
//============ in/out file ============//
//void file() {
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
//}
//============== Prime ===============//
//bool prime(ll n) {
//	if (n == 1)return false;
//	if (n == 2)return true;
//	for (ll i = 2; i*i <= n; i++)
//        if (n % i == 0) return false;
//	return true;
//}
//bool oneway(ll x1, ll y1, ll x2, ll y2, ll x3, ll y3) {
//	ll a = x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2);
//	if (a == 0)return true;
//	return false;
//}
int main()
{
	Mapogo;
	string x, s;
	cin >> x >> s;
	int ans = 0;
	for i(s.size() - x.size() + 1) {
		for r(r, 0, x.size()) {
			if (s[i + r] != x[r])ans++;
		}
	}
	cout << ans;
	return 0;
}


#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WAENINGS
#define Mapogo ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);
typedef long long ll;
#define sortt(a) sort(a.begin(),a.end())
#define r(i,x,n) (int i=x;i<n;i++)
#define i(n) (int i=0;i<n;i++)
#define yes cout<<"yes\n"
#define no cout<<"no\n"
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
#define endl "\n"
#define Pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
using namespace std;
//============== GCD ==================//
//long long gcd(long long a, long long b)
//{
//	if (b == 0)
//		return a;
//	return gcd(b, a % b);
//}
//============== LCM ================       ==//
//int lcm(int a, int b)
//{
//    return (a * b) / gcd(a, b);
//}
//============ Plaindrome =============//
//bool plaindrome(string s) {
//	for (int i = 0, j = s.size() - 1; i < s.size() / 2; i++, j--) {
//		if (s[i] != s[j])
//			return false;
//	}
//	return true;
//}
//============ in/out file ============//
//void file() {
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
//}
//============== Prime ===============//
//bool prime(ll n) {
//	if (n == 1)return false;
//	if (n == 2)return true;
//	for (ll i = 2; i*i <= n; i++)
//        if (n % i == 0) return false;
//	return true;
//}
//bool oneway(ll x1, ll y1, ll x2, ll y2, ll x3, ll y3) {
//	ll a = x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2);
//	if (a == 0)return true;
//	return false;
//}
int main()
{
	Mapogo;
	string x, b;
	cin >> x >> b;
	vector <vector <int>> v(2, vector <int>(b.size() + 1));
	/*if (b[0] == '0')v[0][0] = 1;
	else v[1][0] = 1;*/
	for r(i, 1, b.size() + 1) {
		v[0][i] = v[0][i - 1] + (b[i - 1] == '0');
		v[1][i] = v[1][i - 1] + (b[i - 1] == '1');
	}
	int ans = 0;
	for i(x.size()) {
		if (x[i] == '0')
			ans += v[1][b.size() - x.size() + i + 1] - v[1][i];
		else ans += v[0][b.size() - x.size() + i + 1] - v[0][i];
	}
	cout << ans;
	/*for i(b.size() + 1)cout << v[0][i] << " " << v[1][i] << endl;*/
	return 0;
}


#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WAENINGS
#define Mapogo ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);
typedef long long ll;
#define sortt(a) sort(a.begin(),a.end())
#define r(i,x,n) (int i=x;i<n;i++)
#define i(n) (int i=0;i<n;i++)
#define yes cout<<"yes\n"
#define no cout<<"no\n"
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
#define endl "\n"
#define Pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
using namespace std;
//============== GCD ==================//
//long long gcd(long long a, long long b)
//{
//	if (b == 0)
//		return a;
//	return gcd(b, a % b);
//}
//============== LCM ================       ==//
//int lcm(int a, int b)
//{
//    return (a * b) / gcd(a, b);
//}
//============ Plaindrome =============//
//bool plaindrome(string s) {
//	for (int i = 0, j = s.size() - 1; i < s.size() / 2; i++, j--) {
//		if (s[i] != s[j])
//			return false;
//	}
//	return true;
//}
//============ in/out file ============//
//void file() {
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
//}
//============== Prime ===============//
//bool prime(ll n) {
//	if (n == 1)return false;
//	if (n == 2)return true;
//	for (ll i = 2; i*i <= n; i++)
//        if (n % i == 0) return false;
//	return true;
//}
//bool oneway(ll x1, ll y1, ll x2, ll y2, ll x3, ll y3) {
//	ll a = x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2);
//	if (a == 0)return true;
//	return false;
//}
int main()
{
	Mapogo;
	string x, s;
	cin >> x >> s;
	int ans = 0;
	for i(s.size()) {
		if (s[i] != x[i % x.size()])ans++;
	}
	cout << ans;
	return 0;
}


#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define angle(a) (atan2((a).imag(), (a).real()))
#define vec(a, b) ((b) - (a))
#define length(a) (hypot((a).imag(), (a).real()))
#define dot(a, b) ((conj(a) * (b)).real())
#define cross(a, b) ((conj(a) * (b)).imag())
#define lengthSqr(p) dot(p, p)
#define rotateO(p, ang) ((p) * exp(point(0, ang)))
#define rotateA(p, ang, about) (rotateO(vec(about, p), ang) + about)
#define reflectO(v, m) (conj((v) / (m)) * (m))
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second
#define X() real()
#define Y() imag()
using namespace std;

template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
typedef complex<double> point;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);

int main(){
	FAST_IO
	string a, b; cin >> a >> b;
	int N = SZ(a), M = SZ(b);
	LL distance = 0;
	vector<int> oneC(M + 1, 0);
	for(int idx = 0; idx <= M; ++idx){
		if(idx < M) oneC[idx] = (b[idx] == '1');
		if(idx) oneC[idx] += oneC[idx - 1];
	}

	for(int idx = 0; idx < N; ++idx){
		int oneCount = oneC[M - N + idx] - (idx ? oneC[idx - 1] : 0);
		distance += (a[idx] == '1' ? M - N + 1 - oneCount : oneCount);
	}

	cout << distance << "\n";
}


#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;

template<class T> bool max_self(T & a, const T & b){
  return b > a ? a = b, true : false;
}
template<class T> bool min_self(T & a, const T & b){
  return b < a ? a = b, true : false;
}
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);

string a, b;
int pref[(int)2e5 + 5], N, M;
LL cnt = 0;

int get(int f, int t){
  assert(f <= t);
  return pref[t] - (f ? pref[f - 1] : 0);
}

int main(){
  FAST_IO
  cin >> a >> b;
  N = SZ(a), M = SZ(b);
  for(int idx = 0; idx < N; ++idx){
    pref[idx] = a[idx] - '0';
    if(idx) pref[idx] += pref[idx - 1];
  }

  for(int idx = 0, f, t, ones, zeros; idx < M; ++idx){
    t = min(N - 1, idx);
    f = max(0, N - M + idx);
    ones = get(f, t);
    zeros = t - f + 1 - ones;
    if(b[idx] == '0') cnt += ones;
    else cnt += zeros;
  }

  cout << cnt << '\n';
}


#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;

template<class T> bool max_self(T & a, const T & b){
  return b > a ? a = b, true : false;
}
template<class T> bool min_self(T & a, const T & b){
  return b < a ? a = b, true : false;
}
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);

string a, b;
int pref[(int)2e5 + 5], N, M, cnt = 0;

int get(int f, int t){
  assert(f <= t);
  return pref[t] - (f ? pref[f - 1] : 0);
}

int main(){
  FAST_IO
  cin >> a >> b;
  N = SZ(a), M = SZ(b);
  for(int idx = 0; idx < N; ++idx){
    pref[idx] = a[idx] - '0';
    if(idx) pref[idx] += pref[idx - 1];
  }

  for(int idx = 0, f, t, ones, zeros; idx < M; ++idx){
    t = min(N - 1, idx);
    f = max(0, N - M + idx);
    ones = get(f, t);
    zeros = t - f + 1 - ones;
    if(b[idx] == '0') cnt += ones;
    else cnt += zeros;
  }

  cout << cnt << '\n';
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,o,n) for (int i = o; i <= n; i++)
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define pp pair<ll,ll>
#define vl vector<ll>
#define vpp vector<pp>
#define sorta(v) stable_sort(v.begin(),v.end())
#define sortd(v) stable_sort(v.begin(),v.end(),greater <> ())
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define INF 1000000000
#define endl '\n'
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
#define fast ios::sync_with_stdio(0);cin.tie(0)
#define all(x) x.begin(),x.end()
#define ms(a,v) memset(a,v,sizeof a)
#define II ({int a; scanf("%d", &a); a;})
#define LL ({Long a; scanf("%lld", &a); a;})
#define DD ({double a; scanf("%lf", &a); a;})
#define mp make_pair
#define gc getchar
#define EPS 1e-10
#define pi 3.1415926535897932384626433832795
#define PI acos(-1.0)
#define FI freopen ("in.txt", "r", stdin)
#define FO freopen ("out.txt", "w", stdout)
typedef unsigned long long ull;
typedef set<int> si;
typedef pair<string,ll>psl;
typedef pair<double,double>pdd;

#define forab(i, a, b)	for (__typeof (b) i = (a) ; i <= b ; ++i)
#define rep(i, n)		forab (i, 0, (n) - 1)
#define For(i, n)		forab (i, 1, n)
#define rofba(i, a, b)	for (__typeof (b)i = (b) ; i >= a ; --i)
#define per(i, n)		rofba (i, 0, (n) - 1)
#define rof(i, n)		rofba (i, 1, n)
#define forstl(i, s)	for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)

#ifdef LOCAL
#define __(args...) {dbg,args; cerr<<endl;}
struct debugger{template<typename T> debugger& operator , (const T& v){cerr<<v<<"\t"; return *this; }}dbg;
#define __1D(a,n) rep(i,n) { if(i) printf(" ") ; cout << a[i] ; }
#define __2D(a,r,c,f) forab(i,f,r-!f){forab(j,f,c-!f){if(j!=f)printf(" ");cout<<a[i][j];}cout<<endl;}
#endif
template<class A, class B> ostream &operator<<(ostream& o, const pair<A,B>& p){ return o<<"("<<p.ff<<", "<<p.ss<<")";} //Pair print
template<class T> ostream& operator<<(ostream& o, const vector<T>& v){ o<<"[";forstl(it,v)o<<*it<<", ";return o<<"]";} //Vector print
template<class T> ostream& operator<<(ostream& o, const set<T>& v){ o<<"[";forstl(it,v)o<<*it<<", ";return o<<"]";} //Set print
template<class T> inline void MAX(T &a , T b){ if (a < b ) a = b;}
template<class T> inline void MIN(T &a , T b){ if (a > b ) a = b;}

//Fast Reader
template<class T>inline bool read(T &x){int c=gc();int sgn=1;while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=gc();}for(x=0;~c&&'0'<=c&&c<='9';c=gc())x=x*10+c-'0';x*=sgn;return ~c;}

//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={2,1,-1,-2,-1,1};int dy[]={0,1,1,0,-1,-1}; //Hexagonal Direction
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
int a_sum[200001],b_sum[200001],ans_sum[200001];

int main()
{
    string a; cin>>a;
    int lena=a.length();
    for(int i=1; i<=a.length(); i++)
    {
        a_sum[i]=a[i-1]-'0';
    }
    cin>>a;
    int lenb=a.length();
    for(int i=1; i<=a.length(); i++)
    {
        b_sum[i]=a[i-1]-'0';
        ans_sum[i]=ans_sum[i-1]+b_sum[i];
    }
    ll sum=0;
    for(int i=1; i<=lena; i++)
    {
        if(a_sum[i])
        {
            sum+=lenb-lena+1-(ans_sum[lenb-lena+i]-ans_sum[i-1]);
        }
        else
        {
            sum+=ans_sum[lenb-lena+i]-ans_sum[i-1];
        }
    }
    cout<<sum;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,o,n) for (int i = o; i <= n; i++)
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define pp pair<ll,ll>
#define vl vector<ll>
#define vpp vector<pp>
#define sorta(v) stable_sort(v.begin(),v.end())
#define sortd(v) stable_sort(v.begin(),v.end(),greater <> ())
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define INF 1000000000
#define endl '\n'
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
#define fast ios::sync_with_stdio(0);cin.tie(0)
#define all(x) x.begin(),x.end()
#define ms(a,v) memset(a,v,sizeof a)
#define II ({int a; scanf("%d", &a); a;})
#define LL ({Long a; scanf("%lld", &a); a;})
#define DD ({double a; scanf("%lf", &a); a;})
#define mp make_pair
#define gc getchar
#define EPS 1e-10
#define pi 3.1415926535897932384626433832795
#define PI acos(-1.0)
#define FI freopen ("in.txt", "r", stdin)
#define FO freopen ("out.txt", "w", stdout)
typedef unsigned long long ull;
typedef set<int> si;
typedef pair<string,ll>psl;
typedef pair<double,double>pdd;

#define forab(i, a, b)	for (__typeof (b) i = (a) ; i <= b ; ++i)
#define rep(i, n)		forab (i, 0, (n) - 1)
#define For(i, n)		forab (i, 1, n)
#define rofba(i, a, b)	for (__typeof (b)i = (b) ; i >= a ; --i)
#define per(i, n)		rofba (i, 0, (n) - 1)
#define rof(i, n)		rofba (i, 1, n)
#define forstl(i, s)	for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)

#ifdef LOCAL
#define __(args...) {dbg,args; cerr<<endl;}
struct debugger{template<typename T> debugger& operator , (const T& v){cerr<<v<<"\t"; return *this; }}dbg;
#define __1D(a,n) rep(i,n) { if(i) printf(" ") ; cout << a[i] ; }
#define __2D(a,r,c,f) forab(i,f,r-!f){forab(j,f,c-!f){if(j!=f)printf(" ");cout<<a[i][j];}cout<<endl;}
#endif
template<class A, class B> ostream &operator<<(ostream& o, const pair<A,B>& p){ return o<<"("<<p.ff<<", "<<p.ss<<")";} //Pair print
template<class T> ostream& operator<<(ostream& o, const vector<T>& v){ o<<"[";forstl(it,v)o<<*it<<", ";return o<<"]";} //Vector print
template<class T> ostream& operator<<(ostream& o, const set<T>& v){ o<<"[";forstl(it,v)o<<*it<<", ";return o<<"]";} //Set print
template<class T> inline void MAX(T &a , T b){ if (a < b ) a = b;}
template<class T> inline void MIN(T &a , T b){ if (a > b ) a = b;}

//Fast Reader
template<class T>inline bool read(T &x){int c=gc();int sgn=1;while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=gc();}for(x=0;~c&&'0'<=c&&c<='9';c=gc())x=x*10+c-'0';x*=sgn;return ~c;}

//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={2,1,-1,-2,-1,1};int dy[]={0,1,1,0,-1,-1}; //Hexagonal Direction
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
int a_sum[200001],b_sum[200001],ans_sum[200001];

int main()
{
    string a; cin>>a;
    int lena=a.length();
    for(int i=1; i<=a.length(); i++)
    {
        a_sum[i]=a[i-1]-'0';
    }
    cin>>a;
    int lenb=a.length();
    for(int i=1; i<=a.length(); i++)
    {
        b_sum[i]=a[i-1]-'0';
        ans_sum[i]=ans_sum[i-1]+b_sum[i];
    }
    int sum=0;
    for(int i=1; i<=lena; i++)
    {
        if(a_sum[i])
        {
            sum+=lenb-lena+1-(ans_sum[lenb-lena+i]-ans_sum[i-1]);
        }
        else
        {
            sum+=ans_sum[lenb-lena+i]-ans_sum[i-1];
        }
    }
    cout<<sum;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,o,n) for (int i = o; i <= n; i++)
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define pp pair<ll,ll>
#define vl vector<ll>
#define vpp vector<pp>
#define sorta(v) stable_sort(v.begin(),v.end())
#define sortd(v) stable_sort(v.begin(),v.end(),greater <> ())
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define INF 1000000000
#define endl '\n'
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
#define fast ios::sync_with_stdio(0);cin.tie(0)
#define all(x) x.begin(),x.end()
#define ms(a,v) memset(a,v,sizeof a)
#define II ({int a; scanf("%d", &a); a;})
#define LL ({Long a; scanf("%lld", &a); a;})
#define DD ({double a; scanf("%lf", &a); a;})
#define mp make_pair
#define gc getchar
#define EPS 1e-10
#define pi 3.1415926535897932384626433832795
#define PI acos(-1.0)
#define FI freopen ("in.txt", "r", stdin)
#define FO freopen ("out.txt", "w", stdout)
typedef unsigned long long ull;
typedef set<int> si;
typedef pair<string,ll>psl;
typedef pair<double,double>pdd;

#define forab(i, a, b)	for (__typeof (b) i = (a) ; i <= b ; ++i)
#define rep(i, n)		forab (i, 0, (n) - 1)
#define For(i, n)		forab (i, 1, n)
#define rofba(i, a, b)	for (__typeof (b)i = (b) ; i >= a ; --i)
#define per(i, n)		rofba (i, 0, (n) - 1)
#define rof(i, n)		rofba (i, 1, n)
#define forstl(i, s)	for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)

#ifdef LOCAL
#define __(args...) {dbg,args; cerr<<endl;}
struct debugger{template<typename T> debugger& operator , (const T& v){cerr<<v<<"\t"; return *this; }}dbg;
#define __1D(a,n) rep(i,n) { if(i) printf(" ") ; cout << a[i] ; }
#define __2D(a,r,c,f) forab(i,f,r-!f){forab(j,f,c-!f){if(j!=f)printf(" ");cout<<a[i][j];}cout<<endl;}
#endif
template<class A, class B> ostream &operator<<(ostream& o, const pair<A,B>& p){ return o<<"("<<p.ff<<", "<<p.ss<<")";} //Pair print
template<class T> ostream& operator<<(ostream& o, const vector<T>& v){ o<<"[";forstl(it,v)o<<*it<<", ";return o<<"]";} //Vector print
template<class T> ostream& operator<<(ostream& o, const set<T>& v){ o<<"[";forstl(it,v)o<<*it<<", ";return o<<"]";} //Set print
template<class T> inline void MAX(T &a , T b){ if (a < b ) a = b;}
template<class T> inline void MIN(T &a , T b){ if (a > b ) a = b;}

//Fast Reader
template<class T>inline bool read(T &x){int c=gc();int sgn=1;while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=gc();}for(x=0;~c&&'0'<=c&&c<='9';c=gc())x=x*10+c-'0';x*=sgn;return ~c;}

//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={2,1,-1,-2,-1,1};int dy[]={0,1,1,0,-1,-1}; //Hexagonal Direction
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

int main()
{
    string a; cin>>a;
    string b; cin>>b;
    if((int)a.size()>(int)b.size())
    {
        cout<<0;
        return 0;
    }
    int sum=0;
    for(int i=0; i+(int)a.size()-1<(int)b.size(); i++)
    {
        for(int j=i,k=0; k<(int)a.size(); j++,k++)
        {
            sum+=abs((a[k]-'0')-(b[j]-'0'));
            //cout<<a[k]-'0'<<" "<<b[j]-'0'<<endl;
        }
        cout<<endl;
    }
    cout<<sum;
}