    //23 days left
    //CODEFORCES:-
    //coded by AMAN BHARTI NIT PATNA
    //ECE 2K18

    //After reading solution of kasun]
    //so complicated

    #include<bits/stdc++.h>
    #include <algorithm>
    using namespace std;

    //#define home
    #define TASK "soln"
    #define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
    #define pb push_back
    #define pp pop_back
    #define ll long long int
    #define ull unsigned long long
    #define br cout<<endl
    #define fo for(int i=0;i<n;i++)
    #define foo for(int i=1;i<=n;i++)
    #define rep(i,a,n) for(int i=a;i<n;i++)
    #define repi(i,a,n) for(int i=a;i>=n;i--)
    #define mod 1000000007
    ll gcd(ll a,ll b);
    ll power(ll a,ll b);
    ll powerwithmod(ll a,ll b);
    ll nCr(ll n,ll r);
    ll fact(ll n);

    void solve(){
        ll n,m;
        cin>>n>>m;
        vector<pair<ll,ll>>rob(n),lig(m);
        for(int i=0;i<n;i++){cin>>rob[i].first>>rob[i].second;}
        for(int i=0;i<m;i++){cin>>lig[i].first>>lig[i].second;}

        vector<ll>maxY_atx(10e6+8,0);

        for(int i=0;i<m;i++){
            for(int j=0;j<n;j++){
                if(rob[j].first<=lig[i].first&&rob[j].second<=lig[i].second){
                    ll xdiff = lig[i].first-rob[j].first;
                    ll ydiff = lig[i].second-rob[j].second;
                    maxY_atx[xdiff]=max(maxY_atx[xdiff],ydiff);
                }
                else continue;
            }
        }

        // for(int i=0;i<=10;i++)cout<<maxY_atx[i]<<" ";
        // br;

        ll sol =INT64_MAX;
        ll ymax = 0;
        for(int i=0;i<10e6+8;i++){
            ymax = max(ymax,maxY_atx[i]);
            sol = min(sol,ymax+i);
        }

        cout<<sol;
        br;
    }

    int main(){
         #ifdef home
            assert(freopen(TASK".in","r",stdin));
            assert(freopen(TASK".out","w",stdout));
        #endif

        ios::sync_with_stdio(false);
        cin.tie(NULL);

        // int t;
        // cin>>t;
        // while(t-->0)
        solve();

        #ifdef home
            eprintf("Time: %d ms\n", (int)(clock() * 1000. / CLOCKS_PER_SEC));
        #endif

        return 0;
    }

    ll gcd(ll a,ll b) {if(b==0)return a;return gcd(b,a%b);}
    ll powerwithmod(ll a,ll b) {ll res=1;while(b>0){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return res%mod;}
    ll power(ll a,ll b) {ll res=1;while(b>0){if(b&1)res=(res*a);a=(a*a);b>>=1;}return res;}
    ll nCr(ll n, ll r){return fact(n) / (fact(r) * fact(n - r));}
    ll fact(ll n){ll res = 1;for(ll i = 2; i <= n; i++)res = (res * i)%mod;return (res)%mod;}


////////////////////      We are not beautiful     /////////////////////////////////

//Coded by Aman Bharti (ECE 2k18) Nit Patna

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  // assert(freopen("soln.in","r",stdin));
  // assert(freopen("soln.out","w",stdout));

  ll n,m;
  cin>>n>>m;
  vector<pair<ll,ll>>rob;
  vector<pair<ll,ll>>sl;
  ll maxm[3000005];
  memset(maxm,-1,sizeof(maxm));

  for(int i=0;i<n;i++){
    ll x,y;
    cin>>x>>y;
    rob.push_back({x,y});
  }

  for(int i=0;i<m;i++){
    ll x,y;
    cin>>x>>y;
    sl.push_back({x,y});
  }

  ll ans=INT64_MAX;
  ll mxx=0,mxy=0;

  for(int i=0;i<m;i++)
  for(int j=0;j<n;j++)
  if(rob[j].first<=sl[i].first&&rob[j].second<=sl[i].second)
  maxm[sl[i].first-rob[j].first] = max((maxm[sl[i].first-rob[j].first]),(sl[i].second-rob[j].second));

  for(ll i= 300001;i>=0;i--){
    ans =min(i+mxy+1,ans);
    mxy = max(maxm[i]+1,mxy);
  }
  ans =min(mxy,ans);

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


// NK
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define psf push_front
#define pof pop_front
#define mkp make_pair
#define all(x) x.begin(), x.end()
#define Bolivia_is_nice ios::sync_with_stdio(false), cin.tie(nullptr)

int main(){
	Bolivia_is_nice;
	int n,m; cin>>n>>m;
	vii a(n),b(m);
	for (int i=0; i<n; ++i) cin>>a[i].first>>a[i].second;
	for (int i=0; i<m; ++i) cin>>b[i].first>>b[i].second;

	vi barrier(1000010);
	for (int i=0; i<n; ++i){
		for (int j=0; j<m; ++j){
			if (a[i].first <= b[j].first && a[i].second <= b[j].second){
				barrier[b[j].first - a[i].first] = max(b[j].second - a[i].second + 1, barrier[b[j].first - a[i].first]);
			}
		}
	}
	int ans = 3000000, obstacle = 0;
	for (int x=1000001; x>=0; --x){
		obstacle = max(obstacle, barrier[x]);
		ans = min(ans, x + obstacle);
	}
	cout<<ans<<'\n';
	return 0;
}
/*
  ~/.emacs
*/


// NK
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define psf push_front
#define pof pop_front
#define mkp make_pair
#define all(x) x.begin(), x.end()
#define Bolivia_is_nice ios::sync_with_stdio(false), cin.tie(nullptr)

int main(){
	//Bolivia_is_nice;

	int n,m; scanf("%d%d", &n, &m);
	vii a(n),b(m);
	for (int i=0; i<n; ++i) scanf("%d%d", &a[i].first, &a[i].second);
	for (int i=0; i<m; ++i) scanf("%d%d", &b[i].first, &b[i].second);

	vi barrier(1000010);
	for (int i=0; i<n; ++i){
		for (int j=0; j<m; ++j){
			if (a[i].first <= b[j].first && a[i].second <= b[j].second){
				barrier[b[j].first - a[i].first] = max(b[j].second - a[i].second + 1, barrier[b[j].first - a[i].first]);
			}
		}
	}
	int ans = 3000000, obstacle = 0;
	for (int x=1000001; x>=0; --x){
		obstacle = max(obstacle, barrier[x]);
		ans = min(ans, x + obstacle);
	}
	cout<<ans<<'\n';
	return 0;
}
/*
  ~/.emacs
*/


// NK
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define psf push_front
#define pof pop_front
#define mkp make_pair
#define all(x) x.begin(), x.end()
#define Bolivia_is_nice ios::sync_with_stdio(false), cin.tie(nullptr)

int main(){
	//Bolivia_is_nice;

	int n,m; scanf("%d%d", &n, &m);
	vii a(n),b(m);
	for (int i=0; i<n; ++i) scanf("%d%d", &a[i].first, &a[i].second);
	for (int i=0; i<m; ++i) scanf("%d%d", &b[i].first, &b[i].second);

	vi barrier(1000010);
	for (int i=0; i<n; ++i){
		for (int j=0; j<m; ++j){
			if (a[i].first <= b[j].first && a[i].second <= b[j].second){
				barrier[b[j].first - a[i].first] = b[j].second - a[i].second + 1;
			}
		}
	}
	int ans = 3000000, obstacle = 0;
	for (int x=1000001; x>=0; --x){
		obstacle = max(obstacle, barrier[x]);
		ans = min(ans, x + obstacle);
	}
	cout<<ans<<'\n';
	return 0;
}
/*
  ~/.emacs
*/


// NK
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define psf push_front
#define pof pop_front
#define mkp make_pair
#define all(x) x.begin(), x.end()
#define Bolivia_is_nice ios::sync_with_stdio(false), cin.tie(nullptr)

const int MAXS = 1e6+8;
int st[MAXS*3], lazy[MAXS*3];

void upd(int node, int l, int r, int xr, int val){
	if (lazy[node]){
		st[node] = max(lazy[node], st[node]);
		if (l != r){
			lazy[node*2] = max(lazy[node*2], lazy[node]);
			lazy[node*2+1] = max(lazy[node*2+1], lazy[node]);
		}
		lazy[node]=0;
	}
	if (l > xr) return;
	if (0 <= l && r <= xr){
		st[node]=max(st[node], val);
		if (l != r){
			lazy[node*2] = max(lazy[node*2], val);
			lazy[node*2+1] = max(lazy[node*2+1], val);
		}
		return;
	}
	int mid = (l + r) / 2;
	upd(node*2, l, mid, xr, val);
	upd(node*2+1, mid+1, r, xr, val);
	st[node] = max(st[node*2], st[node*2+1]);
}

int query(int node, int l, int r, int pos){
	if (lazy[node]){
		st[node] = max(lazy[node], st[node]);
		if (l != r){
			lazy[node*2] = max(lazy[node*2], lazy[node]);
			lazy[node*2+1] = max(lazy[node*2+1], lazy[node]);
		}
		lazy[node]=0;
	}
	if (r < pos || l > pos) return 0;
	if (l == r) return st[node];
	int mid = (l + r) / 2;
	return max( query(node*2, l, mid, pos), query(node*2+1, mid+1, r, pos) );
}

int main(){
	int n,m; scanf("%d%d",&n,&m);
	vii a(n),b(m);
	for (int i=0; i<n; ++i) scanf("%d%d", &a[i].first, &a[i].second);
	for (int i=0; i<m; ++i) scanf("%d%d", &b[i].first, &b[i].second);

	for (int i=0; i<n; ++i){
		for (int j=0; j<m; ++j){
			if (a[i].first <= b[j].first && a[i].second <= b[j].second){
				upd(1, 0, MAXS-2, b[j].first - a[i].first, b[j].second - a[i].second + 1);
			}
		}
	}
	int ans = 3000000;
	for (int x=0; x<=1000001; ++x){
		ans = min(ans, x + query(1,0,MAXS-2, x) );
	}
	cout<<ans<<'\n';
	return 0;
}
/*
  ~/.emacs
*/


// NK
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define psf push_front
#define pof pop_front
#define mkp make_pair
#define all(x) x.begin(), x.end()
#define Bolivia_is_nice ios::sync_with_stdio(false), cin.tie(nullptr)

const int MAXS = 1e6+8;
int st[MAXS*3], lazy[MAXS*3];

void upd(int node, int l, int r, int xl, int xr, int val){
	if (lazy[node]){
		st[node] = max(lazy[node], st[node]);
		if (l != r){
			lazy[node*2] = max(lazy[node*2], lazy[node]);
			lazy[node*2+1] = max(lazy[node*2+1], lazy[node]);
		}
		lazy[node]=0;
	}
	if (r < xl || l > xr) return;
	if (xl <= l && r <= xr){
		st[node]=max(st[node], val);
		if (l != r){
			lazy[node*2] = max(lazy[node*2], val);
			lazy[node*2+1] = max(lazy[node*2+1], val);
		}
		return;
	}
	int mid = (l + r) / 2;
	upd(node*2, l, mid, xl, xr, val);
	upd(node*2+1, mid+1, r, xl, xr, val);
	st[node] = max(st[node*2], st[node*2+1]);
}

int query(int node, int l, int r, int pos){
	if (lazy[node]){
		st[node] = max(lazy[node], st[node]);
		if (l != r){
			lazy[node*2] = max(lazy[node*2], lazy[node]);
			lazy[node*2+1] = max(lazy[node*2+1], lazy[node]);
		}
		lazy[node]=0;
	}
	if (r < pos || l > pos) return -10;
	if (l == r) return st[node];
	int mid = (l + r) / 2;
	return max( query(node*2, l, mid, pos), query(node*2+1, mid+1, r, pos) );
}

int main(){
	Bolivia_is_nice;

	int n,m; cin>>n>>m;
	vii a(n),b(m);
	for (int i=0; i<n; ++i) cin>>a[i].first>>a[i].second;
	for (int i=0; i<m; ++i) cin>>b[i].first>>b[i].second;

	for (int i=0; i<n; ++i){
		for (int j=0; j<m; ++j){
			if (a[i].first <= b[j].first && a[i].second <= b[j].second){
				upd(1, 0, MAXS-2, 0, b[j].first - a[i].first, b[j].second - a[i].second + 1);
			}
		}
	}
	int ans = 3000000;
	for (int x=0; x<=1000002; ++x){
		ans = min(ans, x + query(1,0,MAXS-2, x) );
	}
	cout<<ans<<'\n';
	return 0;
}
/*
  ~/.emacs
*/


// NK
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define psf push_front
#define pof pop_front
#define mkp make_pair
#define all(x) x.begin(), x.end()
#define Bolivia_is_nice ios::sync_with_stdio(false), cin.tie(nullptr)

const int MAXS = 1e6+8;
int st[MAXS*3], lazy[MAXS*3];

void upd(int node, int l, int r, int xr, int val){
	if (lazy[node]){
		st[node] = max(lazy[node], st[node]);
		if (l != r){
			lazy[node*2] = max(lazy[node*2], lazy[node]);
			lazy[node*2+1] = max(lazy[node*2+1], lazy[node]);
		}
		lazy[node]=0;
	}
	if (l > xr) return;
	if (0 <= l && r <= xr){
		st[node]=max(st[node], val);
		if (l != r){
			lazy[node*2] = max(lazy[node*2], val);
			lazy[node*2+1] = max(lazy[node*2+1], val);
		}
		return;
	}
	int mid = (l + r) / 2;
	upd(node*2, l, mid, xr, val);
	upd(node*2+1, mid+1, r, xr, val);
	st[node] = max(st[node*2], st[node*2+1]);
}

int query(int node, int l, int r, int pos){
	if (lazy[node]){
		st[node] = max(lazy[node], st[node]);
		if (l != r){
			lazy[node*2] = max(lazy[node*2], lazy[node]);
			lazy[node*2+1] = max(lazy[node*2+1], lazy[node]);
		}
		lazy[node]=0;
	}
	if (r < pos || l > pos) return 0;
	if (l == r) return st[node];
	int mid = (l + r) / 2;
	return max( query(node*2, l, mid, pos), query(node*2+1, mid+1, r, pos) );
}

int main(){
	Bolivia_is_nice;

	int n,m; cin>>n>>m;
	vii a(n),b(m);
	for (int i=0; i<n; ++i) cin>>a[i].first>>a[i].second;
	for (int i=0; i<m; ++i) cin>>b[i].first>>b[i].second;

	for (int i=0; i<n; ++i){
		for (int j=0; j<m; ++j){
			if (a[i].first <= b[j].first && a[i].second <= b[j].second){
				upd(1, 0, MAXS-2, b[j].first - a[i].first, b[j].second - a[i].second + 1);
			}
		}
	}
	int ans = 3000000;
	for (int x=0; x<=1000002; ++x){
		ans = min(ans, x + query(1,0,MAXS-2, x) );
	}
	cout<<ans<<'\n';
	return 0;
}
/*
  ~/.emacs
*/


// NK
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back

const int MAXS = 1e6+8;
int st[MAXS*3], lazy[MAXS*3];

void upd(int node, int l, int r, int xr, int val){
	if (lazy[node]){
		st[node] = max(lazy[node], st[node]);
		if (l != r){
			lazy[node*2] = max(lazy[node*2], lazy[node]);
			lazy[node*2+1] = max(lazy[node*2+1], lazy[node]);
		}
		lazy[node]=0;
	}
	if (l > xr) return;
	if (0 <= l && r <= xr){
		st[node]=max(st[node], val);
		if (l != r){
			lazy[node*2] = max(lazy[node*2], val);
			lazy[node*2+1] = max(lazy[node*2+1], val);
		}
		return;
	}
	int mid = (l + r) / 2;
	upd(node*2, l, mid, xr, val);
	upd(node*2+1, mid+1, r, xr, val);
	st[node] = max(st[node*2], st[node*2+1]);
}

int query(int node, int l, int r, int pos){
	if (lazy[node]){
		st[node] = max(lazy[node], st[node]);
		if (l != r){
			lazy[node*2] = max(lazy[node*2], lazy[node]);
			lazy[node*2+1] = max(lazy[node*2+1], lazy[node]);
		}
		lazy[node]=0;
	}
	if (r < pos || l > pos) return 0;
	if (l == r) return st[node];
	int mid = (l + r) / 2;
	return max( query(node*2, l, mid, pos), query(node*2+1, mid+1, r, pos) );
}

int main(){
	int n,m; scanf("%d%d",&n,&m);
	vii a(n),b(m);
	for (int i=0; i<n; ++i) scanf("%d%d", &a[i].first, &a[i].second);
	for (int i=0; i<m; ++i) scanf("%d%d", &b[i].first, &b[i].second);

	for (int i=0; i<n; ++i){
		for (int j=0; j<m; ++j){
			if (a[i].first <= b[j].first && a[i].second <= b[j].second){
				upd(1, 0, MAXS-2, b[j].first - a[i].first, b[j].second - a[i].second + 1);
			}
		}
	}
	int ans = 3000000;
	for (int x=0; x<=1000001; ++x){
		ans = min(ans, x + query(1,0,MAXS-2, x) );
	}
	cout<<ans<<'\n';
	return 0;
}
/*
  ~/.emacs
*/


// NK
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define psf push_front
#define pof pop_front
#define mkp make_pair
#define all(x) x.begin(), x.end()
#define Bolivia_is_nice ios::sync_with_stdio(false), cin.tie(nullptr)

const int MAXS = 1e6+8;
int st[MAXS*3], lazy[MAXS*3];

void upd(int node, int l, int r, int xl, int xr, int val){
	if (lazy[node]){
		st[node] = max(lazy[node], st[node]);
		if (l != r){
			lazy[node*2] = max(lazy[node*2], lazy[node]);
			lazy[node*2+1] = max(lazy[node*2+1], lazy[node]);
		}
		lazy[node]=0;
	}
	if (r < xl || l > xr) return;
	if (xl <= l && r <= xr){
		st[node]=max(st[node], val);
		if (l != r){
			lazy[node*2] = max(lazy[node*2], val);
			lazy[node*2+1] = max(lazy[node*2+1], val);
		}
		return;
	}
	int mid = (l + r) / 2;
	upd(node*2, l, mid, xl, xr, val);
	upd(node*2+1, mid+1, r, xl, xr, val);
	st[node] = max(st[node*2], st[node*2+1]);
}

int query(int node, int l, int r, int pos){
	if (lazy[node]){
		st[node] = max(lazy[node], st[node]);
		if (l != r){
			lazy[node*2] = max(lazy[node*2], lazy[node]);
			lazy[node*2+1] = max(lazy[node*2+1], lazy[node]);
		}
		lazy[node]=0;
	}
	if (r < pos || l > pos) return -10;
	if (l == r) return st[node];
	int mid = (l + r) / 2;
	return max( query(node*2, l, mid, pos), query(node*2+1, mid+1, r, pos) );
}

int main(){
	Bolivia_is_nice;

	int n,m; cin>>n>>m;
	vii a(n),b(m);
	for (int i=0; i<n; ++i) cin>>a[i].first>>a[i].second;
	for (int i=0; i<m; ++i) cin>>b[i].first>>b[i].second;

	for (int i=0; i<n; ++i){
		for (int j=0; j<m; ++j){
			if (a[i].first <= b[j].first && a[i].second <= b[j].second){
				upd(1, 0, MAXS-2, 0, b[j].first - a[i].first, b[j].second - a[i].second + 1);
			}
		}
	}
	int ans = 3000000;
	for (int x=0; x<=1000002; ++x){
		ans = min(ans, x + query(1,0,MAXS-1, x) );
	}
	cout<<ans<<'\n';
	return 0;
}
/*
  ~/.emacs
*/


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define mod 1000000007
vector<pair<int,int>>a,b;
unordered_map<int,int>dp;
bool check(int x,int y){
bool ok=1;
for(int i=0;i<b.size();i++){
    for(int j=0;j<a.size();j++){
        if(b[i].first>=a[j].first+x&&b[i].second>=a[j].second+y){
            int z=b[i].first-a[j].first;
            dp[z]=max(dp[z],b[i].second-a[j].second+1);
        }
    }
}
return 1;
}
bool ye(int x,int y){
return dp[x+1]<y;
return 0;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,m;
cin>>n>>m;
a=vector<pair<int,int>>(n);
b=vector<pair<int,int>>(m);
for(int i=0;i<n;i++){
    cin>>a[i].first>>a[i].second;
}
for(int i=0;i<m;i++){
    cin>>b[i].first>>b[i].second;
}
sort(a.begin(),a.end());

sort(b.begin(),b.end());
reverse(b.begin(),b.end());
check(0,0);
for(int i=1000000;i>=0;i--){
    dp[i]=max(dp[i+1],dp[i]);
}

int ans=mod;
for(int i=0;i<=1000000;i++){
    int l=0,r=1000000;
    int best=r;
    while(l<=r){
        int mid=(l+r)/2;
        if(ye(i,mid)){
            best=min(best,mid);
            r=mid-1;
        }
        else l=mid+1;
    }
    ans=min(ans,i+best);
}
cout<<ans<<'\n';
return 0;}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define mod 1000000007
vector<pair<int,int>>a,b;
unordered_map<int,int>dp;
bool check(int x,int y){
bool ok=1;
for(int i=0;i<b.size();i++){
    for(int j=0;j<a.size();j++){
        if(b[i].first>=a[j].first+x&&b[i].second>=a[j].second+y){
            int z=b[i].first-a[j].first+1;
            dp[z]=max(dp[z],b[i].second-a[j].second+1);
        }
    }
}
return 1;
}
bool ye(int x,int y){
return dp[x+1]<=y;
return 0;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,m;
cin>>n>>m;
a=vector<pair<int,int>>(n);
b=vector<pair<int,int>>(m);
for(int i=0;i<n;i++){
    cin>>a[i].first>>a[i].second;
}
for(int i=0;i<m;i++){
    cin>>b[i].first>>b[i].second;
}
sort(a.begin(),a.end());

sort(b.begin(),b.end());
reverse(b.begin(),b.end());
check(0,0);
for(int i=2000000;i>=0;i--){
    dp[i]=max(dp[i+1],dp[i]);
}

int ans=mod;
for(int i=0;i<=2000000;i++){
    int l=0,r=2000000;
    int best=r;
    while(l<=r){
        int mid=(l+r)/2;
        if(ye(i,mid)){
            best=min(best,mid);
            r=mid-1;
        }
        else l=mid+1;
    }
    ans=min(ans,i+best);
}
cout<<ans<<'\n';
return 0;}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define mod 1000000007
vector<pair<int,int>>a,b;
unordered_map<int,int>dp;
bool check(int x,int y){
bool ok=1;
for(int i=0;i<b.size();i++){
    for(int j=0;j<a.size();j++){
        if(b[i].first>=a[j].first+x&&b[i].second>=a[j].second+y){
            int z=b[i].first-a[j].first;
           dp[z]=max(dp[z],b[i].second-a[j].second);
        }
    }
}
return 1;
}
bool ye(int x,int y){
return dp[x]<=y;
return 0;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,m;
cin>>n>>m;
a=vector<pair<int,int>>(n);
b=vector<pair<int,int>>(m);
for(int i=0;i<n;i++){
    cin>>a[i].first>>a[i].second;
}
for(int i=0;i<m;i++){
    cin>>b[i].first>>b[i].second;
}
sort(a.begin(),a.end());

sort(b.begin(),b.end());
reverse(b.begin(),b.end());
check(0,0);
for(int i=1000000;i>=0;i--){
    dp[i]=max(dp[i+1],dp[i]);
}

int ans=mod;
for(int i=0;i<=1000000;i++){
    int l=0,r=1000000;
    int best=r;
    while(l<=r){
        int mid=(l+r)/2;
        if(ye(i,mid)){
            best=min(best,mid);
            r=mid-1;
        }
        else l=mid+1;
    }
    ans=min(ans,i+best);
}
cout<<ans<<'\n';
return 0;}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define mod 1000000007
vector<pair<int,int>>a,b;
unordered_map<int,pair<int,int>>dp;
set<int>X;
set<int>Y;
bool check(int x,int y){
bool ok=1;
for(int i=0;i<b.size();i++){
    for(int j=0;j<a.size();j++){
        if(b[i].first>=a[j].first+x&&b[i].second>=a[j].second+y){
           X.insert(b[i].first-a[j].first);
           Y.insert(b[i].second-a[j].second);
        }
    }
}
return 1;
}
bool ye(int x,int y){
if(X.size()==0)return 1;
if(Y.size()==0)return 1;
auto it=X.rbegin();
auto it2=Y.rbegin();
if(x>=*it&&y>=*it2)return 1;
return 0;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,m;
cin>>n>>m;
a=vector<pair<int,int>>(n);
b=vector<pair<int,int>>(m);
for(int i=0;i<n;i++){
    cin>>a[i].first>>a[i].second;
}
for(int i=0;i<m;i++){
    cin>>b[i].first>>b[i].second;
}
sort(a.begin(),a.end());

sort(b.begin(),b.end());
reverse(b.begin(),b.end());
check(0,0);
int ans=mod;
for(int i=0;i<=1000000;i++){
    int l=0,r=1000000;
    int best=r;
    while(l<=r){
        int mid=(l+r)/2;
        if(ye(i,mid)){
            best=min(best,mid);
            r=mid-1;
        }
        else l=mid+1;
    }
    ans=min(ans,i+best);
}
cout<<ans<<'\n';
return 0;}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define mod 1000000007
vector<pair<int,int>>a,b;
unordered_map<int,int>dp;
bool check(int x,int y){
bool ok=1;
for(int i=0;i<b.size();i++){
    for(int j=0;j<a.size();j++){
        if(b[i].first>=a[j].first+x&&b[i].second>=a[j].second+y){
            int z=b[i].first-a[j].first;
           dp[z]=max(dp[z],b[i].second-a[j].second);
        }
    }
}
return 1;
}
bool ye(int x,int y){
return dp[x]<=y;
return 0;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,m;
cin>>n>>m;
a=vector<pair<int,int>>(n);
b=vector<pair<int,int>>(m);
for(int i=0;i<n;i++){
    cin>>a[i].first>>a[i].second;
}
for(int i=0;i<m;i++){
    cin>>b[i].first>>b[i].second;
}
sort(a.begin(),a.end());

sort(b.begin(),b.end());
reverse(b.begin(),b.end());
check(0,0);
for(int i=1;i<=1000000;i++){
    dp[i]=max(dp[i-1],dp[i]);
}

int ans=mod;
for(int i=0;i<=1000000;i++){
    int l=0,r=1000000;
    int best=r;
    while(l<=r){
        int mid=(l+r)/2;
        if(ye(i,mid)){
            best=min(best,mid);
            r=mid-1;
        }
        else l=mid+1;
    }
    ans=min(ans,i+best);
}
cout<<ans<<'\n';
return 0;}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define mod 1000000007
vector<pair<int,int>>a,b;
unordered_map<int,pair<int,int>>dp;
bool check(int x,int y){
bool ok=1;
for(int i=0;i<b.size();i++){
    for(int j=0;j<a.size();j++){
        if(b[i].first>=a[j].first+x&&b[i].second>=a[j].second+y){
            return 0;
        }
        else return 1;
    }
}
return 1;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,m;
cin>>n>>m;
a=vector<pair<int,int>>(n);
b=vector<pair<int,int>>(m);
for(int i=0;i<n;i++){
    cin>>a[i].first>>a[i].second;
}
for(int i=0;i<m;i++){
    cin>>b[i].first>>b[i].second;
}
sort(a.begin(),a.end());

sort(b.begin(),b.end());
reverse(b.begin(),b.end());
int ans=mod;
for(int i=0;i<=1000000;i++){
    int l=0,r=1000000;
    int best=r;
    while(l<=r){
        int mid=(l+r)/2;
        if(check(i,mid)){
            best=min(best,mid);
            r=mid-1;
        }
        else l=mid+1;
    }
    ans=min(ans,i+best);
}
cout<<ans<<'\n';
return 0;}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define mod 1000000007
vector<pair<int,int>>a,b;
unordered_map<int,pair<int,int>>dp;
set<int>X;
set<int>Y;
bool check(int x,int y){
bool ok=1;
for(int i=0;i<b.size();i++){
    for(int j=0;j<a.size();j++){
        if(b[i].first>=a[j].first+x&&b[i].second>=a[j].second+y){
           X.insert(b[i].first-a[j].first);
           Y.insert(b[i].second-a[j].second);
        }
    }
}
return 1;
}
bool ye(int x,int y){
if(X.size()==0)return 1;
if(Y.size()==0)return 1;
auto it=X.rbegin();
auto it2=Y.rbegin();
if(x>=*it&&y>=*it2)return 1;
return 0;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,m;
cin>>n>>m;
a=vector<pair<int,int>>(n);
b=vector<pair<int,int>>(m);
for(int i=0;i<n;i++){
    cin>>a[i].first>>a[i].second;
}
for(int i=0;i<m;i++){
    cin>>b[i].first>>b[i].second;
}
sort(a.begin(),a.end());
check(0,0);
sort(b.begin(),b.end());
reverse(b.begin(),b.end());
int ans=mod;
for(int i=0;i<=1000000;i++){
    int l=0,r=1000000;
    int best=r;
    while(l<=r){
        int mid=(l+r)/2;
        if(ye(i,mid)){
            best=min(best,mid);
            r=mid-1;
        }
        else l=mid+1;
    }
    ans=min(ans,i+best);
}
cout<<ans<<'\n';
return 0;}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define mod 1000000007
vector<pair<int,int>>a,b;
unordered_map<int,pair<int,int>>dp;
set<int>X;
set<int>Y;
bool check(int x,int y){
bool ok=1;
for(int i=0;i<b.size();i++){
    for(int j=0;j<a.size();j++){
        if(b[i].first>=a[j].first+x&&b[i].second>=a[j].second+y){
           X.insert(b[i].first-a[j].first);
           Y.insert(b[i].second-a[j].second);
        }
    }
}
return 1;
}
bool ye(int x,int y){
if(X.size()==0)return 1;
if(Y.size()==0)return 1;
auto it=X.rbegin();
auto it2=Y.rbegin();
if(x>=*it||y>=*it2)return 1;
return 0;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,m;
cin>>n>>m;
a=vector<pair<int,int>>(n);
b=vector<pair<int,int>>(m);
for(int i=0;i<n;i++){
    cin>>a[i].first>>a[i].second;
}
for(int i=0;i<m;i++){
    cin>>b[i].first>>b[i].second;
}
sort(a.begin(),a.end());

sort(b.begin(),b.end());
reverse(b.begin(),b.end());
check(0,0);
int ans=mod;
for(int i=0;i<=1000000;i++){
    int l=0,r=1000000;
    int best=r;
    while(l<=r){
        int mid=(l+r)/2;
        if(ye(i,mid)){
            best=min(best,mid);
            r=mid-1;
        }
        else l=mid+1;
    }
    ans=min(ans,i+best);
}
cout<<ans<<'\n';
return 0;}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define mod 1000000007
vector<pair<int,int>>a,b;
unordered_map<int,pair<int,int>>dp;
set<int>X;
set<int>Y;
bool check(int x,int y){
bool ok=1;
for(int i=0;i<b.size();i++){
    for(int j=0;j<a.size();j++){
        if(b[i].first>=a[j].first+x&&b[i].second>=a[j].second+y){
           X.insert(b[i].first-a[j].first);
           Y.insert(b[i].second-a[j].second);
        }
    }
}
return 1;
}
bool ye(int x,int y){
auto it=X.rbegin();
auto it2=Y.rbegin();
if(x>*it&&y>*it2)return 1;
return 0;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,m;
cin>>n>>m;
a=vector<pair<int,int>>(n);
b=vector<pair<int,int>>(m);

check(0,0);
for(int i=0;i<n;i++){
    cin>>a[i].first>>a[i].second;
}
for(int i=0;i<m;i++){
    cin>>b[i].first>>b[i].second;
}
sort(a.begin(),a.end());

sort(b.begin(),b.end());
reverse(b.begin(),b.end());
int ans=mod;
for(int i=0;i<=1000000;i++){
    int l=0,r=1000000;
    int best=r;
    while(l<=r){
        int mid=(l+r)/2;
        if(ye(i,mid)){
            best=min(best,mid);
            r=mid-1;
        }
        else l=mid+1;
    }
    ans=min(ans,i+best);
}
cout<<ans<<'\n';
return 0;}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define mod 1000000007
vector<pair<int,int>>a,b;
unordered_map<int,pair<int,int>>dp;
bool check(int x,int y){
bool ok=1;
for(int i=0;i<b.size();i++){
    for(int j=0;j<a.size();j++){
        if(b[i].first>=a[j].first+x&&b[i].second>=a[j].second+y){
            return 0;
        }
    }
}
return 1;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,m;
cin>>n>>m;
a=vector<pair<int,int>>(n);
b=vector<pair<int,int>>(m);
for(int i=0;i<n;i++){
    cin>>a[i].first>>a[i].second;
}
for(int i=0;i<m;i++){
    cin>>b[i].first>>b[i].second;
}
sort(a.begin(),a.end());
sort(b.begin(),b.end());
int ans=mod;
for(int i=0;i<=1000000;i++){
    int l=0,r=1000000;
    int best=r;
    while(l<=r){
        int mid=(l+r)/2;
        if(check(i,mid)){
            best=min(best,mid);
            r=mid-1;
        }
        else l=mid+1;
    }
    ans=min(ans,i+best);
}
cout<<ans<<'\n';
return 0;}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define mod 1000000007
vector<pair<int,int>>a,b;
unordered_map<int,pair<int,int>>dp;
set<int>X;
set<int>Y;
bool check(int x,int y){
bool ok=1;
for(int i=0;i<b.size();i++){
    for(int j=0;j<a.size();j++){
        if(b[i].first>=a[j].first+x&&b[i].second>=a[j].second+y){
           X.insert(b[i].first-a[j].first);
           Y.insert(b[i].second-a[j].second);
        }
    }
}
return 1;
}
bool ye(int x,int y){
if(X.size()==0)return 1;
if(Y.size()==0)return 1;
auto it=X.rbegin();
auto it2=Y.rbegin();
if(x>*it||y>*it2)return 1;
return 0;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,m;
cin>>n>>m;
a=vector<pair<int,int>>(n);
b=vector<pair<int,int>>(m);
for(int i=0;i<n;i++){
    cin>>a[i].first>>a[i].second;
}
for(int i=0;i<m;i++){
    cin>>b[i].first>>b[i].second;
}
sort(a.begin(),a.end());

sort(b.begin(),b.end());
reverse(b.begin(),b.end());
check(0,0);
int ans=mod;
for(int i=0;i<=1000000;i++){
    int l=0,r=1000000;
    int best=r;
    while(l<=r){
        int mid=(l+r)/2;
        if(ye(i,mid)){
            best=min(best,mid);
            r=mid-1;
        }
        else l=mid+1;
    }
    ans=min(ans,i+best);
}
cout<<ans<<'\n';
return 0;}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define mod 1000000007
vector<pair<int,int>>a,b;
unordered_map<int,int>dp;
bool check(int x,int y){
bool ok=1;
for(int i=0;i<b.size();i++){
    for(int j=0;j<a.size();j++){
        if(b[i].first>=a[j].first+x&&b[i].second>=a[j].second+y){
            int z=b[i].first-a[j].first+1;
            dp[z]=max(dp[z],b[i].second-a[j].second+1);
        }
    }
}
return 1;
}
bool ye(int x,int y){
return dp[x+1]<=y;
return 0;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,m;
cin>>n>>m;
a=vector<pair<int,int>>(n);
b=vector<pair<int,int>>(m);
for(int i=0;i<n;i++){
    cin>>a[i].first>>a[i].second;
}
for(int i=0;i<m;i++){
    cin>>b[i].first>>b[i].second;
}
sort(a.begin(),a.end());

sort(b.begin(),b.end());
reverse(b.begin(),b.end());
check(0,0);
for(int i=1000000;i>=0;i--){
    dp[i]=max(dp[i+1],dp[i]);
}

int ans=mod;
for(int i=0;i<=1000000;i++){
    int l=0,r=1000000;
    int best=r;
    while(l<=r){
        int mid=(l+r)/2;
        if(ye(i,mid)){
            best=min(best,mid);
            r=mid-1;
        }
        else l=mid+1;
    }
    ans=min(ans,i+best);
}
cout<<ans<<'\n';
return 0;}


import java.util.*;
public class code2 {
	public static boolean check(String str,String str2)
	{
		int count=0;
		for(int i=0;i<str.length();i++)
		{
			if(str.charAt(i)!=str2.charAt(i))count++;
		}
		if(count%2==0)
			return true;
		return false;
	}
	public static void main(String args[])
	{
		Scanner s=new Scanner(System.in);
		String a=s.next();
		String b=s.next();
		int n=a.length();
		long count=0;
		TreeSet<Integer>ones=new TreeSet<>();
		TreeSet<Integer>zeros=new TreeSet<>();

		TreeSet<Integer>onesPat=new TreeSet<>();
		TreeSet<Integer>zerosPat=new TreeSet<>();

		for(int i=0;i<b.length();i++)
		{
			if(b.charAt(i)=='1')
				onesPat.add(i);
			else if(b.charAt(i)=='0')
				zerosPat.add(i);
			if(a.charAt(i)=='1')
				ones.add(i);
			else if(a.charAt(i)=='0')
				zeros.add(i);
		}
		int step=1;
		long ans=0;
		for(Integer a1:ones)
		{
			if(!onesPat.contains(a1))
				count++;
		}
		for(Integer a1:zeros)
		{
			if(!zerosPat.contains(a1))
				count++;
		}
		if(count%2==0)
			ans++;
		for(int i=b.length();i<a.length();i++)
		{
			count=0;
			if(a.charAt(i-1)=='1')
			{
				ones.remove(i-1);
			}else
				zeros.remove(i-1);
			if(a.charAt(i)=='1')
				ones.add(i);
			else
				zeros.add(i);

			for(Integer a1:ones)
			{
				if(!onesPat.contains(a1-step))
					count++;
			}
			for(Integer a1:zeros)
			{
				if(!zerosPat.contains(a1-step))
					count++;
			}
			if(count%2==0)
				ans++;
			step++;
		}

		System.out.println(ans);
	}

}


import java.util.*;
public class code2 {
	public static boolean check(String str,String str2)
	{
		int count=0;
		for(int i=0;i<str.length();i++)
		{
			if(str.charAt(i)!=str2.charAt(i))count++;
		}
		if(count%2==0)
			return true;
		return false;
	}
	public static void main(String args[])
	{
		Scanner s=new Scanner(System.in);
		String a=s.next();
		String b=s.next();
		int n=a.length();
		long count=0;
		long counta=0;
		for(int i=0;i<b.length();i++)
		{
			if(b.charAt(i)=='1')
				count++;
			if(a.charAt(i)=='1')
				counta++;
		}
		long ans=0;
		if((counta-count)%2==0)ans++;
		for(int i=b.length();i<a.length();i++)
		{
			if(a.charAt(i-b.length())=='1')
					counta--;
			if(a.charAt(i)=='1')
				counta++;

			if((counta-count)%2==0)
				ans++;
		}

		System.out.println(ans);
	}

}


import java.util.*;
public class code2 {
	public static boolean check(String str,String str2)
	{
		int count=0;
		for(int i=0;i<str.length();i++)
		{
			if(str.charAt(i)!=str2.charAt(i))count++;
		}
		if(count%2==0)
			return true;
		return false;
	}
	public static void main(String args[])
	{
		Scanner s=new Scanner(System.in);
		String a=s.next();
		String b=s.next();
		int n=a.length();
		long count=0;
		TreeSet<Integer>ones=new TreeSet<>();
		TreeSet<Integer>zeros=new TreeSet<>();

		TreeSet<Integer>onesPat=new TreeSet<>();
		TreeSet<Integer>zerosPat=new TreeSet<>();

		for(int i=0;i<b.length();i++)
		{
			if(b.charAt(i)=='1')
				onesPat.add(i);
			else if(b.charAt(i)=='0')
				zerosPat.add(i);
			if(a.charAt(i)=='1')
				ones.add(i);
			else if(a.charAt(i)=='0')
				zeros.add(i);
		}
		int step=1;
		long ans=0;
		for(Integer a1:ones)
		{
			if(!onesPat.contains(a1))
				count++;
		}
		for(Integer a1:zeros)
		{
			if(!zerosPat.contains(a1))
				count++;
		}
		if(count%2==0)
			ans++;
		for(int i=b.length();i<a.length();i++)
		{
			count=0;
			//System.out.println("i "+i);
			if(a.charAt(i-b.length())=='1')
			{
				ones.remove(i-b.length());
			}else
				zeros.remove(i-b.length());
			if(a.charAt(i)=='1')
				ones.add(i);
			else
				zeros.add(i);

			for(Integer a1:ones)
			{
				if(!onesPat.contains(a1-step))
					count++;
			}
			for(Integer a1:zeros)
			{
				if(!zerosPat.contains(a1-step))
					count++;
			}

			if(count%2==0)
				ans++;
			step++;
		}

		System.out.println(ans);
	}

}


import java.util.*;
import java.io.*;
import java.awt.Point;
import java.math.BigInteger;

public class binary_string {

	public static void main(String[] args) throws Exception {
		FastIO sc = new FastIO(System.in);
		PrintWriter pw = new PrintWriter(System.out);

		String a, b;
		a = sc.next();
		b = sc.next();

		int[] prefix = new int[a.length()+1];
		for(int i = 1; i <= a.length(); i++) {
			prefix[i] = prefix[i-1]^(a.charAt(i-1)-'0');
		}

		int xor_of_b = 0;
		for(int i = 0; i < b.length(); i++) xor_of_b ^= b.charAt(i)-'0';

		int count = 0;
		for(int i = 0; i < a.length()-b.length()+1; i++) {
			int xor_of_a = prefix[i+b.length()]-prefix[i];

			if((xor_of_a ^ xor_of_b) == 0) count++;
		}

		pw.println(count);
		pw.close();

	}

	static class FastIO {

		//Is your Fast I/O being bad?

		InputStream dis;
		byte[] buffer = new byte[1 << 17];
		int pointer = 0;

		public FastIO(String fileName) throws Exception {
			dis = new FileInputStream(fileName);
		}

		public FastIO(InputStream is) throws Exception {
			dis = is;
		}

		int nextInt() throws Exception {
			int ret = 0;

			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			boolean negative = false;
			if (b == '-') {
				negative = true;
				b = nextByte();
			}
			while (b >= '0' && b <= '9') {
				ret = 10 * ret + b - '0';
				b = nextByte();
			}

			return (negative) ? -ret : ret;
		}

		long nextLong() throws Exception {
			long ret = 0;

			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			boolean negative = false;
			if (b == '-') {
				negative = true;
				b = nextByte();
			}
			while (b >= '0' && b <= '9') {
				ret = 10 * ret + b - '0';
				b = nextByte();
			}

			return (negative) ? -ret : ret;
		}

		byte nextByte() throws Exception {
			if (pointer == buffer.length) {
				dis.read(buffer, 0, buffer.length);
				pointer = 0;
			}
			return buffer[pointer++];
		}

		String next() throws Exception {
			StringBuffer ret = new StringBuffer();

			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			while (b > ' ') {
				ret.appendCodePoint(b);
				b = nextByte();
			}

			return ret.toString();
		}

	}
}


import java.util.*;
import java.io.*;
import java.awt.Point;
import java.math.BigInteger;

public class binary_string {

	public static void main(String[] args) throws Exception {
		FastIO sc = new FastIO(System.in);
		PrintWriter pw = new PrintWriter(System.out);

		String a, b;
		a = sc.next();
		b = sc.next();

		int[] prefix = new int[a.length()+1];
		for(int i = 1; i <= a.length(); i++) {
			prefix[i] = prefix[i-1]^(a.charAt(i-1)-'0');
		}

		int xor_of_b = 0;
		for(int i = 0; i < b.length(); i++) xor_of_b ^= b.charAt(i)-'0';

		int count = 0;
		for(int i = 0; i < a.length()-b.length()+1; i++) {
			int xor_of_a = prefix[i+b.length()]^prefix[i];

			if((xor_of_a ^ xor_of_b) == 0) count++;
		}

		pw.println(count);
		pw.close();

	}

	static class FastIO {

		//Is your Fast I/O being bad?

		InputStream dis;
		byte[] buffer = new byte[1 << 17];
		int pointer = 0;

		public FastIO(String fileName) throws Exception {
			dis = new FileInputStream(fileName);
		}

		public FastIO(InputStream is) throws Exception {
			dis = is;
		}

		int nextInt() throws Exception {
			int ret = 0;

			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			boolean negative = false;
			if (b == '-') {
				negative = true;
				b = nextByte();
			}
			while (b >= '0' && b <= '9') {
				ret = 10 * ret + b - '0';
				b = nextByte();
			}

			return (negative) ? -ret : ret;
		}

		long nextLong() throws Exception {
			long ret = 0;

			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			boolean negative = false;
			if (b == '-') {
				negative = true;
				b = nextByte();
			}
			while (b >= '0' && b <= '9') {
				ret = 10 * ret + b - '0';
				b = nextByte();
			}

			return (negative) ? -ret : ret;
		}

		byte nextByte() throws Exception {
			if (pointer == buffer.length) {
				dis.read(buffer, 0, buffer.length);
				pointer = 0;
			}
			return buffer[pointer++];
		}

		String next() throws Exception {
			StringBuffer ret = new StringBuffer();

			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			while (b > ' ') {
				ret.appendCodePoint(b);
				b = nextByte();
			}

			return ret.toString();
		}

	}
}


import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

/* Niks Patel */

public class codeforces implements Runnable{

    public void run(){

        InputReader s = new InputReader(System.in);
        PrintWriter w = new PrintWriter(System.out);

        int t = 1;
        while(t-->0){

            String a = s.next();
            String b = s.next();
            int lena = a.length();
            int lenb = b.length();
            int bone = b.replaceAll("0","").length();
            int ans = 0, count1=0;
            String str = a.substring(0,lenb);
            for(int i=0;i<str.length();i++){
                if(str.charAt(i)=='1') count1++;
            }
            if((count1%2==0 && bone%2==0) || (count1%2==1 && bone%2==1)) ans++;
            for(int i=str.length(),j=0;i<lena;i++,j++){
                if(a.charAt(i)!=a.charAt(j) && a.charAt(i)=='1') count1++;
                else if (a.charAt(i)!=a.charAt(j) && a.charAt(i)=='0') count1--;
                if((count1%2==0 && bone%2==0) || (count1%2==1 && bone%2==1)) ans++;
            }
            w.println(ans);
        }

        w.close();
    }

    static class InputReader
    {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream)
        {
            this.stream = stream;
        }

        public int read(){

            if (numChars==-1)
                throw new InputMismatchException();

            if (curChar >= numChars)
            {
                curChar = 0;
                try
                {
                    numChars = stream.read(buf);
                }
                catch (IOException e)
                {
                    throw new InputMismatchException();
                }

                if(numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextLine()
        {
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
        public int nextInt()
        {
            int c = read();

            while(isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-')
            {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do
            {
                if(c<'0'||c>'9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public long nextLong()
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-')
            {
                sgn = -1;
                c = read();
            }
            long res = 0;

            do
            {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
            return res * sgn;
        }

        public double nextDouble()
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-')
            {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.')
            {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.')
            {
                c = read();
                double m = 1;
                while (!isSpaceChar(c))
                {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

        public String readString()
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do
            {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));

            return res.toString();
        }

        public boolean isSpaceChar(int c)
        {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next()
        {
            return readString();
        }

        public interface SpaceCharFilter
        {
            public boolean isSpaceChar(int ch);
        }
    }

    public static void main(String args[]) throws Exception
    {
        new Thread(null, new codeforces(),"codeforces",1<<26).start();
    }

}


import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

/* Niks Patel */

public class codeforces implements Runnable{

    public void run(){

        InputReader s = new InputReader(System.in);
        PrintWriter w = new PrintWriter(System.out);

        int t = 1;
        while(t-->0){

            String a = s.next();
            String b = s.next();
            int lena = a.length();
            int lenb = b.length();
            int  bone = b.replaceAll("0","").length();
            int ans = 0;
            for(int i=0;i<(lena-lenb+1);i++){
                String str = a.substring(i,lenb+i);
                int strone = str.replaceAll("0","").length();
                if((bone%2==0 && strone%2==0) || (bone%2==1 && strone%2==1)) ans++;
            }
            w.println(ans);
        }

        w.close();
    }

    static class InputReader
    {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream)
        {
            this.stream = stream;
        }

        public int read(){

            if (numChars==-1)
                throw new InputMismatchException();

            if (curChar >= numChars)
            {
                curChar = 0;
                try
                {
                    numChars = stream.read(buf);
                }
                catch (IOException e)
                {
                    throw new InputMismatchException();
                }

                if(numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextLine()
        {
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
        public int nextInt()
        {
            int c = read();

            while(isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-')
            {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do
            {
                if(c<'0'||c>'9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public long nextLong()
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-')
            {
                sgn = -1;
                c = read();
            }
            long res = 0;

            do
            {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
            return res * sgn;
        }

        public double nextDouble()
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-')
            {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.')
            {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.')
            {
                c = read();
                double m = 1;
                while (!isSpaceChar(c))
                {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

        public String readString()
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do
            {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));

            return res.toString();
        }

        public boolean isSpaceChar(int c)
        {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next()
        {
            return readString();
        }

        public interface SpaceCharFilter
        {
            public boolean isSpaceChar(int ch);
        }
    }

    public static void main(String args[]) throws Exception
    {
        new Thread(null, new codeforces(),"codeforces",1<<26).start();
    }

}


import java.util.*;

public class Main {

    private static int getOneNum(String b) {
        int ans = 0;
        for (char ch : b.toCharArray()) {
            if (ch == '1') {
                ans += 1;
            }
        }
        return ans;
    }

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);

        String a , b;
        a = scan.next();
        b = scan.next();

        int i , length = a.length() , bCnt = getOneNum(b) , aCnt = 0 , ans = 0;
        for (i = 0;i < b.length() - 1;i ++) {
            if (a.charAt(i) == '1') {
                aCnt += 1;
            }
        }
        for (i = b.length() - 1;i < length;i ++) {
            if (a.charAt(i) == '1') {
                aCnt += 1;
            }
            if (aCnt % 2 == bCnt % 2) {
                ans ++;
            }
            if (a.charAt(i - (b.length() - 1)) == '1') {
                aCnt --;
            }
        }
        System.out.println(ans);

    }

}


import java.util.*;

public class Main {

    private static int getOneNum(String b) {
        int ans = 0;
        for (char ch : b.toCharArray()) {
            if (ch == '1') {
                ans += 1;
            }
        }
        return ans;
    }

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);

        String a , b;
        a = scan.next();
        b = scan.next();

        int i , length = a.length() , bCnt = getOneNum(b) , aCnt = 0 , ans = 0;
        for (i = 0;i < b.length() - 1;i ++) {
            if (b.charAt(i) == '1') {
                aCnt += 1;
            }
        }
        for (i = b.length() - 1;i < length;i ++) {
            if (a.charAt(i) == '1') {
                aCnt += 1;
            }
            if (aCnt % 2 == bCnt % 2) {
                ans ++;
            }
            if (a.charAt(i - (b.length() - 1)) == '1') {
                aCnt --;
            }
        }
        System.out.println(ans);

    }

}


//package Round571;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.*;

public class typeC {
	static class FastReader

    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
	public static void main(String[] args) {
		FastReader s = new FastReader();
		String str1 = s.nextLine();
		String str2 = s.nextLine();
		int count1=0;
		int[] arr = new int[str1.length()+1];
		for(int i=0;i<str1.length();i++) {
			if(str1.charAt(i)=='1') {
				arr[i+1]=arr[i]+1;
				count1++;
			}else {
				arr[i+1]=arr[i];
			}
		}
	//	System.out.println(count1);
		int count=0;
		for(int i=0;i<str2.length();i++) {
			if(str2.charAt(i)=='1') {
				count++;
			}
		}
	//	System.out.println(count);
		int len2 = str2.length();
		int ans=0;
		for(int i=0;i<=str1.length()-len2;i++) {
//			String str3 = str1.substring(i,i+len2);
			//System.out.println(str3);
			int total = arr[i+len2]-arr[i];
			//System.out.println(total);
			if((total-count)%2==0) {
				ans++;
			}
		}
		System.out.println(ans);

	}
}


//package Round571;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.*;

public class typeC {
	static class FastReader

    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
	public static void main(String[] args) {
		FastReader s = new FastReader();
		String str1 = s.nextLine();
		String str2 = s.nextLine();
		int count1=0;
		int[] arr = new int[str1.length()+1];
		for(int i=0;i<str1.length();i++) {
			if(str1.charAt(i)=='1') {
				arr[i+1]=arr[i]+1;
				count1++;
			}else {
				arr[i+1]=arr[i];
			}
		}
	//	System.out.println(count1);
		int count=0;
		for(int i=0;i<str2.length();i++) {
			if(str2.charAt(i)=='1') {
				count++;
			}
		}
	//	System.out.println(count);
		int len2 = str2.length();
		int ans=0;
		for(int i=0;i<=str1.length()-len2;i++) {
			String str3 = str1.substring(i,i+len2);
			//System.out.println(str3);
			int total = arr[i+len2]-arr[i];
			//System.out.println(total);
			if((total-count)%2==0) {
				ans++;
			}
		}
		System.out.println(ans);

	}
}


import java.io.*;
import java.util.Arrays;
import java.util.StringJoiner;
import java.util.StringTokenizer;

public class MainC {

    static String A, B;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        A = sc.next();
        B = sc.next();

        System.out.println(solve());
    }

    static int solve() {
        int p = 0;
        for (int i = 0; i < B.length(); i++) {
            if( B.charAt(i) == '1' ) p++;
        }

        int ans = 0;
        int q = 0;
        for (int i = 0; i < B.length(); i++) {
            if( A.charAt(i) == '1' ) q++;
        }
        if( p%2 == q%2 ) ans++;

        for (int i = B.length(); i < A.length(); i++) {
            if( A.charAt(i) == '1' ) q++;
            if( A.charAt(i-B.length()) == '1' ) q--;
            if( p%2 == q%2 ) ans++;
        }
        return ans;
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        int[] nextIntArray(int n, int delta) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt() + delta;
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) a[i] = nextLong();
            return a;
        }
    }

    static void writeLines(int[] as) {
        PrintWriter pw = new PrintWriter(System.out);
        for (int a : as) pw.println(a);
        pw.flush();
    }

    static void writeLines(long[] as) {
        PrintWriter pw = new PrintWriter(System.out);
        for (long a : as) pw.println(a);
        pw.flush();
    }

    static void writeSingleLine(int[] as) {
        PrintWriter pw = new PrintWriter(System.out);
        for (int i = 0; i < as.length; i++) {
            if (i != 0) pw.print(" ");
            pw.print(as[i]);
        }
        pw.println();
        pw.flush();
    }

    static int max(int... as) {
        int max = Integer.MIN_VALUE;
        for (int a : as) max = Math.max(a, max);
        return max;
    }

    static int min(int... as) {
        int min = Integer.MAX_VALUE;
        for (int a : as) min = Math.min(a, min);
        return min;
    }

    static void debug(Object... args) {
        StringJoiner j = new StringJoiner(" ");
        for (Object arg : args) {
            if (arg == null) j.add("null");
            else if (arg instanceof int[]) j.add(Arrays.toString((int[]) arg));
            else if (arg instanceof long[]) j.add(Arrays.toString((long[]) arg));
            else if (arg instanceof double[]) j.add(Arrays.toString((double[]) arg));
            else if (arg instanceof Object[]) j.add(Arrays.toString((Object[]) arg));
            else j.add(arg.toString());
        }
        System.err.println(j.toString());
    }

    static void printSingleLine(int[] array) {
        PrintWriter pw = new PrintWriter(System.out);
        for (int i = 0; i < array.length; i++) {
            if (i != 0) pw.print(" ");
            pw.print(array[i]);
        }
        pw.println();
        pw.flush();
    }

    static int lowerBound(int[] array, int value) {
        int lo = 0, hi = array.length, mid;
        while (lo < hi) {
            mid = (hi + lo) / 2;
            if (array[mid] < value) lo = mid + 1;
            else hi = mid;
        }
        return lo;
    }

    static int upperBound(int[] array, int value) {
        int lo = 0, hi = array.length, mid;
        while (lo < hi) {
            mid = (hi + lo) / 2;
            if (array[mid] <= value) lo = mid + 1;
            else hi = mid;
        }
        return lo;
    }
}


import java.util.Scanner;

/**
 *
 * @author Haya
 */
public class VusTheCossackAndStrings {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        String a = in.next();
        String b = in.next();

        int len = b.length();
        int counter = 0;

        int dif = 0;
        for (int i = 0; i < len; i++) {
            if (a.charAt(i)!=b.charAt(i))
                dif++;

        }
        if (dif%2==0)
            counter++;

        for (int i = len; i < a.length(); i++) {

            if (a.charAt(i)!=a.charAt(i-1))
                dif++;

            if (dif%2==0)
                counter++;
        }

        System.out.println(counter);

        /*
        while (lastIndex != a.length()+1){

            String sub = a.substring(pointer, lastIndex);

            if (countDif(b, sub))
                counter++;

            pointer++;
            lastIndex++;

        }

        System.out.println(counter);
        */

    }

    public static boolean countDif(String a, String b){
        int count = 0;

        for (int i = 0; i < a.length(); i++) {

            if (a.charAt(i)!=b.charAt(i))
                count++;
        }

        return count%2==0;

    }

}


import java.util.Scanner;

/**
 *
 * @author Haya
 */
public class VusTheCossackAndStrings {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        String a = in.next();
        String b = in.next();

        int lastIndex = b.length();
        int pointer = 0;
        int counter = 0;

        while (lastIndex != a.length()){

            String sub = a.substring(pointer, lastIndex);

            if (countDif(b, sub))
                counter++;

            pointer++;
            lastIndex++;

        }

        System.out.println(counter);

    }

    public static boolean countDif(String a, String b){
        int count = 0;

        for (int i = 0; i < a.length(); i++) {

            if (a.charAt(i)!=b.charAt(i))
                count++;
        }

        return count%2==0;

    }

}


import java.util.Scanner;

/**
 *
 * @author Haya
 */
public class VusTheCossackAndStrings {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        String a = in.next();
        String b = in.next();

        int len = b.length();
        int counter = 0;

        int dif = 0;
        for (int i = 0; i < len; i++) {
            if (a.charAt(i)!=b.charAt(i))
                dif++;

        }
        if (dif%2==0)
            counter++;

        for (int i = len; i < a.length(); i++) {

            if (a.charAt(i)!=a.charAt(i-len))
                dif++;

            if (dif%2==0)
                counter++;
        }

        System.out.println(counter);

    }

    public static boolean countDif(String a, String b){
        int count = 0;

        for (int i = 0; i < a.length(); i++) {

            if (a.charAt(i)!=b.charAt(i))
                count++;
        }

        return count%2==0;

    }

}


import java.util.Scanner;

/**
 *
 * @author Haya
 */
public class VusTheCossackAndStrings {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        String a = in.next();
        String b = in.next();

        int lastIndex = b.length();
        int pointer = 0;
        int counter = 0;

        while (lastIndex != a.length()+1){

            String sub = a.substring(pointer, lastIndex);

            if (countDif(b, sub))
                counter++;

            pointer++;
            lastIndex++;

        }

        System.out.println(counter);

    }

    public static boolean countDif(String a, String b){
        int count = 0;

        for (int i = 0; i < a.length(); i++) {

            if (a.charAt(i)!=b.charAt(i))
                count++;
        }

        return count%2==0;

    }

}


import java.util.Scanner;

/**
 *
 * @author Haya
 */
public class VusTheCossackAndStrings {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        String a = in.next();
        String b = in.next();

        int lastIndex = b.length();
        int pointer = 0;
        int counter = 0;
        int count = 0;

        for (int i = 0; i < a.length(); i++) {

            String sub = a.substring(i,lastIndex);

            for (int j = 0; j < sub.length(); j++) {

                if (sub.charAt(i)!=b.charAt(i))
                    count++;

            }
            if (count %2 ==0)
                counter++;

            if (i == a.length()-b.length())
                break;

            lastIndex++;

        }

        System.out.println(counter);
        /*
        while (lastIndex != a.length()+1){

            String sub = a.substring(pointer, lastIndex);

            if (countDif(b, sub))
                counter++;

            pointer++;
            lastIndex++;

        }

        System.out.println(counter);
        */

    }

    public static boolean countDif(String a, String b){
        int count = 0;

        for (int i = 0; i < a.length(); i++) {

            if (a.charAt(i)!=b.charAt(i))
                count++;
        }

        return count%2==0;

    }

}


import java.util.Scanner;

/**
 *
 * @author Haya
 */
public class VusTheCossackAndStrings {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        String a = in.next();
        String b = in.next();

        int lastIndex = b.length();
        int pointer = 0;
        int counter = 0;

        for (int i = 0; i < a.length(); i++) {

            String sub = a.substring(i,lastIndex);

            if (countDif(b, sub))
                counter++;

            if (i == a.length()-b.length())
                break;

            lastIndex++;

        }

        System.out.println(counter);
        /*
        while (lastIndex != a.length()+1){

            String sub = a.substring(pointer, lastIndex);

            if (countDif(b, sub))
                counter++;

            pointer++;
            lastIndex++;

        }

        System.out.println(counter);
        */

    }

    public static boolean countDif(String a, String b){
        int count = 0;

        for (int i = 0; i < a.length(); i++) {

            if (a.charAt(i)!=b.charAt(i))
                count++;
        }

        return count%2==0;

    }

}


import java.util.Scanner;

/**
 *
 * @author Haya
 */
public class VusTheCossackAndStrings {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        String a = in.next();
        String b = in.next();

        int lastIndex = b.length();
        int pointer = 0;
        int counter = 0;

        int dif = 0;
        for (int i = 0; i < lastIndex; i++) {
            if (a.charAt(i)!=b.charAt(i))
                dif++;

        }
        if (dif%2==0)
            counter++;

        for (int i = lastIndex; i < a.length(); i++) {

            if (a.charAt(i)!=a.charAt(i-1))
                dif++;

            if (dif%2==0)
                counter++;
        }

        System.out.println(counter);

        /*
        while (lastIndex != a.length()+1){

            String sub = a.substring(pointer, lastIndex);

            if (countDif(b, sub))
                counter++;

            pointer++;
            lastIndex++;

        }

        System.out.println(counter);
        */

    }

    public static boolean countDif(String a, String b){
        int count = 0;

        for (int i = 0; i < a.length(); i++) {

            if (a.charAt(i)!=b.charAt(i))
                count++;
        }

        return count%2==0;

    }

}


import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.reflect.Array;

public class C {
    static final int MOD = 1000000007; // 1e9 + 7
    static final boolean AUTO_FLUSH = false; // slow if true
    // int = num(); // long = ll();
    // string = next(); // a string line = line();
    // ---------------------------------- \

    void main() throws Exception {
        String a = line(), b = line();
        int ans = 0;
        int curr = -1;
        int diff = 0;
        for (int i = 1; i < b.length(); i++)
            if (b.charAt(i) != b.charAt(i-1))
                diff++;
            else
                diff--;
        for (int i = 0; i <= a.length()-b.length(); i++) {
            if (curr == -1) {
                curr = 0;
                for (int j = 0; j < b.length(); j++)
                    if (a.charAt(i+j) != b.charAt(j))
                        curr++;
            } else {
                if (a.charAt(i-1) != b.charAt(0))
                    curr--;
                if (a.charAt(i+b.length()-1) != b.charAt(b.length()-1))
                    curr++;
                curr += diff;
            }
            if (curr%2 == 0)
                ans++;
        }
        outln(ans);
    }

    // ---------------------------------- \
    //#region
    public static void main(String[] args) throws Exception {
        new Thread(null, () -> {
            try {
                if (!ONLINE_JUDGE)
                    startTime();
                new C().main();
                boolean endsWithEnter = TO_BE_PRINTED.length() == 0 || TO_BE_PRINTED.charAt(TO_BE_PRINTED.length() - 1) == '\n';
                flush();
                if (ONLINE_JUDGE)
                    return;
                if (!endsWithEnter)
                    log('\n');
                logTime();
                logMem();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }, "Main", 1<<26).start();
    }
    static Random RAND = new Random();
    static int random(int from, int to) {
        return RAND.nextInt(to-from+1)+from;
    }
    static void logTime() {
        log("Time: " + getTime() + "ms");
    }
    static void logMem() {
        log("Memory (End): " + (int) (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024 + " KB");
    }
    static long ll() {
        return Long.parseLong(next());
    }
    static int num() {
        return Integer.parseInt(next());
    }
    static void generateInputMode() throws Exception {
        System.setOut(new PrintStream(new FileOutputStream("F://PROGRAMMING/input.txt")));
    }
    static String line() {
        if (!tokenize())
            return null;
        INPUT_STREAM.setLength(0);
        if (STRING_TOKENIZER.hasMoreTokens())
            INPUT_STREAM.append(STRING_TOKENIZER.nextToken());
        while (STRING_TOKENIZER.hasMoreTokens())
            INPUT_STREAM.append(' ').append(STRING_TOKENIZER.nextToken());
        return INPUT_STREAM.length() == 0 ? null : INPUT_STREAM.toString();
    }
    static void startTime() {
        TIME_COMPLEXITY = System.currentTimeMillis();
    }
    static long getTime() {
        return System.currentTimeMillis() - TIME_COMPLEXITY;
    }
    static void flush() {
        System.out.print(TO_BE_PRINTED.toString());
        TO_BE_PRINTED.setLength(0);
    }
    static void out(Object o) {
        TO_BE_PRINTED.append(o);
        if (AUTO_FLUSH)
            flush();
    }
    static void _log(String s) {
        System.err.print(s);
    }
    static void _logln(String s) {
        System.err.println(s);
    }
    static void _logln() {
        System.err.println();
    }
    static void outln(Object o) {
        out(o);
        outln();
    }
    static void outln() {
        out("\n");
    }
    static class Pair implements Comparable<Pair> {
        public int a, b;
        public Pair(int a, int b) {
            this.a = a;
            this.b = b;
        }
        public static Pair of(int a, int b) {
            return new Pair(a, b);
        }
        public int compareTo(Pair p) {
            if (a == p.a)
                return Integer.compare(b, p.b);
            return Integer.compare(a, p.a);
        }
        public String toString() {
            return "[" + a + "," + b + "]";
        }
        public boolean equals(Pair p) {
            return p.a == a && p.b == b;
        }
    }
    static boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
    static void logArr(Object val) {
        if (ONLINE_JUDGE)
            return;
        Class<?> valKlass = val.getClass();
        Object[] outputArray = null;
        for(Class<?> arrKlass : new Class<?>[] { int[].class, float[].class, double[].class, boolean[].class,
            byte[].class, short[].class, long[].class, char[].class }) {
            if (valKlass.isAssignableFrom(arrKlass)) {
                int arrlength = Array.getLength(val);
                outputArray = new Object[arrlength];
                for(int i = 0; i < arrlength; ++i)
                    outputArray[i] = Array.get(val, i);
                break;
            }
        }
        if(outputArray == null)
            outputArray = (Object[])val;
        logArr0(outputArray);
    }
    static void logArr0(Object[] objs) {
        if (ONLINE_JUDGE)
            return;
        if (objs.length == 0) {
            _log("* \n");
            return;
        }
        _log("* " + objs[0]);
        for (int i = 1; i < objs.length; i++)
            _log(objs[i].toString().equals("\n") ? "\n>" : (" " + objs[i]));
        _logln();
    }
    static void log(Object... objs) {
        if (ONLINE_JUDGE)
            return;
        logArr0(objs);
    }
    static String next() {
        return tokenize() ? STRING_TOKENIZER.nextToken() : null;
    }
    static boolean tokenize() {
        if (STRING_TOKENIZER == null || !STRING_TOKENIZER.hasMoreTokens()) {
            try {
                STRING_TOKENIZER = new StringTokenizer(STREAM_READER.readLine());
            } catch (Exception e) {
                return false;
            }
        }
        return true;
    }
    static long TIME_COMPLEXITY;
    static BufferedReader STREAM_READER = new BufferedReader(new InputStreamReader(System.in), 32768);
    static StringTokenizer STRING_TOKENIZER;
    static StringBuilder INPUT_STREAM = new StringBuilder(), TO_BE_PRINTED = new StringBuilder();
    //#endregion
}


import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.reflect.Array;

public class C {
    static final int MOD = 1000000007; // 1e9 + 7
    static final boolean AUTO_FLUSH = false; // slow if true
    // int = num(); // long = ll();
    // string = next(); // a string line = line();
    // ---------------------------------- \

    void main() throws Exception {
        String a = line(), b = line();
        HashMap<String, Boolean> map = new HashMap<>();
        int ans = 0;
        for (int i = 0; i <= a.length()-b.length(); i++) {
            String str = a.substring(i, i+b.length());
            if (map.get(str) != null) {
                if (map.get(str))
                    ans++;
                continue;
            }
            int count = 0;
            for (int j = 0; j < b.length(); j++)
                if (str.charAt(j) != b.charAt(j))
                    count++;
            map.put(str, count%2 == 0);
            if (count%2 == 0)
                ans++;
        }
        outln(ans);
    }

    // ---------------------------------- \
    //#region
    public static void main(String[] args) throws Exception {
        new Thread(null, () -> {
            try {
                if (!ONLINE_JUDGE)
                    startTime();
                new C().main();
                boolean endsWithEnter = TO_BE_PRINTED.length() == 0 || TO_BE_PRINTED.charAt(TO_BE_PRINTED.length() - 1) == '\n';
                flush();
                if (ONLINE_JUDGE)
                    return;
                if (!endsWithEnter)
                    log('\n');
                logTime();
                logMem();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }, "Main", 1<<26).start();
    }
    static Random RAND = new Random();
    static int random(int from, int to) {
        return RAND.nextInt(to-from+1)+from;
    }
    static void logTime() {
        log("Time: " + getTime() + "ms");
    }
    static void logMem() {
        log("Memory (End): " + (int) (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024 + " KB");
    }
    static long ll() {
        return Long.parseLong(next());
    }
    static int num() {
        return Integer.parseInt(next());
    }
    static void generateInputMode() throws Exception {
        System.setOut(new PrintStream(new FileOutputStream("F://PROGRAMMING/input.txt")));
    }
    static String line() {
        if (!tokenize())
            return null;
        INPUT_STREAM.setLength(0);
        if (STRING_TOKENIZER.hasMoreTokens())
            INPUT_STREAM.append(STRING_TOKENIZER.nextToken());
        while (STRING_TOKENIZER.hasMoreTokens())
            INPUT_STREAM.append(' ').append(STRING_TOKENIZER.nextToken());
        return INPUT_STREAM.length() == 0 ? null : INPUT_STREAM.toString();
    }
    static void startTime() {
        TIME_COMPLEXITY = System.currentTimeMillis();
    }
    static long getTime() {
        return System.currentTimeMillis() - TIME_COMPLEXITY;
    }
    static void flush() {
        System.out.print(TO_BE_PRINTED.toString());
        TO_BE_PRINTED.setLength(0);
    }
    static void out(Object o) {
        TO_BE_PRINTED.append(o);
        if (AUTO_FLUSH)
            flush();
    }
    static void _log(String s) {
        System.err.print(s);
    }
    static void _logln(String s) {
        System.err.println(s);
    }
    static void _logln() {
        System.err.println();
    }
    static void outln(Object o) {
        out(o);
        outln();
    }
    static void outln() {
        out("\n");
    }
    static class Pair implements Comparable<Pair> {
        public int a, b;
        public Pair(int a, int b) {
            this.a = a;
            this.b = b;
        }
        public static Pair of(int a, int b) {
            return new Pair(a, b);
        }
        public int compareTo(Pair p) {
            if (a == p.a)
                return Integer.compare(b, p.b);
            return Integer.compare(a, p.a);
        }
        public String toString() {
            return "[" + a + "," + b + "]";
        }
        public boolean equals(Pair p) {
            return p.a == a && p.b == b;
        }
    }
    static boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
    static void logArr(Object val) {
        if (ONLINE_JUDGE)
            return;
        Class<?> valKlass = val.getClass();
        Object[] outputArray = null;
        for(Class<?> arrKlass : new Class<?>[] { int[].class, float[].class, double[].class, boolean[].class,
            byte[].class, short[].class, long[].class, char[].class }) {
            if (valKlass.isAssignableFrom(arrKlass)) {
                int arrlength = Array.getLength(val);
                outputArray = new Object[arrlength];
                for(int i = 0; i < arrlength; ++i)
                    outputArray[i] = Array.get(val, i);
                break;
            }
        }
        if(outputArray == null)
            outputArray = (Object[])val;
        logArr0(outputArray);
    }
    static void logArr0(Object[] objs) {
        if (ONLINE_JUDGE)
            return;
        if (objs.length == 0) {
            _log("* \n");
            return;
        }
        _log("* " + objs[0]);
        for (int i = 1; i < objs.length; i++)
            _log(objs[i].toString().equals("\n") ? "\n>" : (" " + objs[i]));
        _logln();
    }
    static void log(Object... objs) {
        if (ONLINE_JUDGE)
            return;
        logArr0(objs);
    }
    static String next() {
        return tokenize() ? STRING_TOKENIZER.nextToken() : null;
    }
    static boolean tokenize() {
        if (STRING_TOKENIZER == null || !STRING_TOKENIZER.hasMoreTokens()) {
            try {
                STRING_TOKENIZER = new StringTokenizer(STREAM_READER.readLine());
            } catch (Exception e) {
                return false;
            }
        }
        return true;
    }
    static long TIME_COMPLEXITY;
    static BufferedReader STREAM_READER = new BufferedReader(new InputStreamReader(System.in), 32768);
    static StringTokenizer STRING_TOKENIZER;
    static StringBuilder INPUT_STREAM = new StringBuilder(), TO_BE_PRINTED = new StringBuilder();
    //#endregion
}


import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.reflect.Array;

public class C {
    static final int MOD = 1000000007; // 1e9 + 7
    static final boolean AUTO_FLUSH = false; // slow if true
    // int = num(); // long = ll();
    // string = next(); // a string line = line();
    // ---------------------------------- \

    void main() throws Exception {
        String a = line(), b = line();
        int ans = 0;
        int curr = -1;
        int diff = 0;
        for (int i = 1; i < b.length(); i++)
            if (b.charAt(i) != b.charAt(i-1))
                diff++;
        for (int i = 0; i <= a.length()-b.length(); i++) {
            if (curr == -1) {
                curr = 0;
                for (int j = 0; j < b.length(); j++)
                    if (a.charAt(i+j) != b.charAt(j))
                        curr++;
            } else {
                if (a.charAt(i-1) != b.charAt(0))
                    curr--;
                if (a.charAt(i+b.length()-1) != b.charAt(b.length()-1))
                    curr++;
                curr += diff;
            }
            if (curr%2 == 0)
                ans++;
        }
        outln(ans);
    }

    // ---------------------------------- \
    //#region
    public static void main(String[] args) throws Exception {
        new Thread(null, () -> {
            try {
                if (!ONLINE_JUDGE)
                    startTime();
                new C().main();
                boolean endsWithEnter = TO_BE_PRINTED.length() == 0 || TO_BE_PRINTED.charAt(TO_BE_PRINTED.length() - 1) == '\n';
                flush();
                if (ONLINE_JUDGE)
                    return;
                if (!endsWithEnter)
                    log('\n');
                logTime();
                logMem();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }, "Main", 1<<26).start();
    }
    static Random RAND = new Random();
    static int random(int from, int to) {
        return RAND.nextInt(to-from+1)+from;
    }
    static void logTime() {
        log("Time: " + getTime() + "ms");
    }
    static void logMem() {
        log("Memory (End): " + (int) (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024 + " KB");
    }
    static long ll() {
        return Long.parseLong(next());
    }
    static int num() {
        return Integer.parseInt(next());
    }
    static void generateInputMode() throws Exception {
        System.setOut(new PrintStream(new FileOutputStream("F://PROGRAMMING/input.txt")));
    }
    static String line() {
        if (!tokenize())
            return null;
        INPUT_STREAM.setLength(0);
        if (STRING_TOKENIZER.hasMoreTokens())
            INPUT_STREAM.append(STRING_TOKENIZER.nextToken());
        while (STRING_TOKENIZER.hasMoreTokens())
            INPUT_STREAM.append(' ').append(STRING_TOKENIZER.nextToken());
        return INPUT_STREAM.length() == 0 ? null : INPUT_STREAM.toString();
    }
    static void startTime() {
        TIME_COMPLEXITY = System.currentTimeMillis();
    }
    static long getTime() {
        return System.currentTimeMillis() - TIME_COMPLEXITY;
    }
    static void flush() {
        System.out.print(TO_BE_PRINTED.toString());
        TO_BE_PRINTED.setLength(0);
    }
    static void out(Object o) {
        TO_BE_PRINTED.append(o);
        if (AUTO_FLUSH)
            flush();
    }
    static void _log(String s) {
        System.err.print(s);
    }
    static void _logln(String s) {
        System.err.println(s);
    }
    static void _logln() {
        System.err.println();
    }
    static void outln(Object o) {
        out(o);
        outln();
    }
    static void outln() {
        out("\n");
    }
    static class Pair implements Comparable<Pair> {
        public int a, b;
        public Pair(int a, int b) {
            this.a = a;
            this.b = b;
        }
        public static Pair of(int a, int b) {
            return new Pair(a, b);
        }
        public int compareTo(Pair p) {
            if (a == p.a)
                return Integer.compare(b, p.b);
            return Integer.compare(a, p.a);
        }
        public String toString() {
            return "[" + a + "," + b + "]";
        }
        public boolean equals(Pair p) {
            return p.a == a && p.b == b;
        }
    }
    static boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
    static void logArr(Object val) {
        if (ONLINE_JUDGE)
            return;
        Class<?> valKlass = val.getClass();
        Object[] outputArray = null;
        for(Class<?> arrKlass : new Class<?>[] { int[].class, float[].class, double[].class, boolean[].class,
            byte[].class, short[].class, long[].class, char[].class }) {
            if (valKlass.isAssignableFrom(arrKlass)) {
                int arrlength = Array.getLength(val);
                outputArray = new Object[arrlength];
                for(int i = 0; i < arrlength; ++i)
                    outputArray[i] = Array.get(val, i);
                break;
            }
        }
        if(outputArray == null)
            outputArray = (Object[])val;
        logArr0(outputArray);
    }
    static void logArr0(Object[] objs) {
        if (ONLINE_JUDGE)
            return;
        if (objs.length == 0) {
            _log("* \n");
            return;
        }
        _log("* " + objs[0]);
        for (int i = 1; i < objs.length; i++)
            _log(objs[i].toString().equals("\n") ? "\n>" : (" " + objs[i]));
        _logln();
    }
    static void log(Object... objs) {
        if (ONLINE_JUDGE)
            return;
        logArr0(objs);
    }
    static String next() {
        return tokenize() ? STRING_TOKENIZER.nextToken() : null;
    }
    static boolean tokenize() {
        if (STRING_TOKENIZER == null || !STRING_TOKENIZER.hasMoreTokens()) {
            try {
                STRING_TOKENIZER = new StringTokenizer(STREAM_READER.readLine());
            } catch (Exception e) {
                return false;
            }
        }
        return true;
    }
    static long TIME_COMPLEXITY;
    static BufferedReader STREAM_READER = new BufferedReader(new InputStreamReader(System.in), 32768);
    static StringTokenizer STRING_TOKENIZER;
    static StringBuilder INPUT_STREAM = new StringBuilder(), TO_BE_PRINTED = new StringBuilder();
    //#endregion
}


/******************************************************************************

                            Online Java Compiler.
                Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.

*******************************************************************************/
import java.util.*;
public class Main
{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=1;
		while(t-->0)
		{
		    String a=sc.next();
		    String b=sc.next();
		    char[] arr,brr;
		    arr=a.toCharArray();
		    brr=b.toCharArray();
		    int l1=a.length();
		    int l2=b.length();
		    int p[]=new int[l1+1];
		    p[0]=0;
		    for(int i=0;i<l1;i++)
		    {
		        int x=0;
		        if(arr[i]=='1')
		            x=1;
		        p[i+1]=p[i]+x;

		    }
		    int y=0,ans=0;
		    for(int i=0;i<l2;i++)
		    {
		        if(brr[i]=='1')
		        y++;
		    }
		    for(int i=0;i+l2-1<l1;i++)
		    {
		        int x=p[i+l2]-p[i];
		        if((x%2)==(y%2))
		        ans++;

		    }
		    System.out.println(ans);
		}
	}
}


/******************************************************************************

                            Online Java Compiler.
                Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.

*******************************************************************************/
import java.util.*;
public class Main
{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=1;
		while(t-->0)
		{
		    String a=sc.next();
		    String b=sc.next();
		    char[] arr,brr;
		    arr=a.toCharArray();
		    brr=b.toCharArray();
		    int l1=a.length();
		    int l2=b.length();
		    int p[]=new int[l1+1];
		    p[0]=0;
		    for(int i=0;i<l1;i++)
		    {
		        int x=0;
		        if(arr[i]=='1')
		            x=1;
		        p[i+1]=p[i]+x;
		    }
		    int y=0,ans=0;
		    for(int i=0;i<l2;i++)
		    {
		        if(brr[i]=='1')
		        y++;
		    }
		    for(int i=0;i+l2-1<l1;i++)
		    {
		        int x=p[i]-p[i+l2];
		        if(x%2==y%2)
		        ans++;
		    }
		    System.out.println(ans);
		}
	}
}


import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;

public class Main {
	public static void main(String[] args) throws IOException {
		InputReader sc=new InputReader(System.in);
		PrintWriter out=new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		char[] a=sc.next().toCharArray();
		char[] b=sc.next().toCharArray();
		int ans=0;
		int sum=0;
		for(int i=0;i<b.length;i++)
			sum^=a[i]-'0';
		if(sum==0)
			ans++;
		for(int i=b.length;i<a.length;i++) {
			if(a[i-b.length]=='1')
				sum^=1;
			if(a[i]=='1')
				sum^=1;
			if(sum==0)
				ans++;
		}
		out.println(ans);
		out.flush();
	}
}

class InputReader {
    private InputStreamReader reader;
    private char[] buf;
    private int len, now;

    public InputReader(InputStream stream) {
        reader = new InputStreamReader(stream);
        buf = new char[1024];
        len = 0;
        now = 0;
    }

    public String next() throws IOException {
        if (!hasNext()) throw new NullPointerException();
        StringBuilder sb = new StringBuilder();
        while (!isSpaceChar(buf[now])) {
            sb.append(buf[now]);
            if (!move()) break;
        }
        return sb.toString();
    }

    public int nextInt() throws IOException {
        if (!hasNext()) throw new NullPointerException();
        boolean x = false;
        if (buf[now] == '-') {
            x = true;
            if (!move()) throw new NumberFormatException();
        }
        int ans = 0;
        while (!isSpaceChar(buf[now])) {
            if (isNum(buf[now])) ans = ans * 10 + buf[now] - '0';
            else throw new NumberFormatException();
            if (!move()) break;
        }
        return (x ? -1 : 1) * ans;
    }

    public String nextLine() throws IOException {
        if (!hasNextLine()) throw new NullPointerException();
        StringBuilder sb = new StringBuilder();
        while (buf[now] != '\n') {
            sb.append(buf[now]);
            if (!move()) return sb.toString();
        }
        now++;
        return sb.toString();
    }

    public long nextLong() throws IOException {
        if (!hasNext()) throw new NullPointerException();
        boolean x = false;
        if (buf[now] == '-') {
            x = true;
            if (!move()) throw new NumberFormatException();
        }
        long ans = 0;
        while (!isSpaceChar(buf[now])) {
            if (isNum(buf[now])) ans = ans * 10 + buf[now] - '0';
            else throw new NumberFormatException();
            if (!move()) break;
        }
        return (x ? -1 : 1) * ans;
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    public int nextHexInt() throws IOException {
        if (!hasNext()) throw new NullPointerException();
        boolean x = false;
        if (buf[now] == '-') {
            x = true;
            if (!move()) throw new NumberFormatException();
        }
        int ans = 0;
        while (!isSpaceChar(buf[now])) {
            if (isHex(buf[now])) ans = ans * 16 + toHex(buf[now]);
            else throw new NumberFormatException();
            if (!move()) break;
        }
        return (x ? -1 : 1) * ans;
    }

    public char nextChar() throws IOException {
        if (!hasNext()) throw new NullPointerException();
        char tmp = buf[now];
        move();
        return tmp;
    }
    public int next(char[] s) throws IOException {
        if (!hasNext()) throw new NullPointerException();
        int len=0;
        while (!isSpaceChar(buf[now])&&len<s.length) {
            s[len++]=buf[now];
            if (!move()) break;
        }
        return len;
    }
    public boolean hasNext() throws IOException {
        return skip();
    }

    public boolean hasNextLine() throws IOException {
        return now < len || refill();
    }

    private boolean move() throws IOException {
        now++;
        return hasNextLine();
    }

    private boolean skip() throws IOException {
        if (!hasNextLine()) return false;
        while (isSpaceChar(buf[now])) {
            if (!move()) return false;
        }
        return true;
    }

    private boolean isSpaceChar(char c) {
        return !(c >= 33 && c <= 126);
    }

    private boolean isNum(char c) {
        return c >= '0' && c <= '9';
    }

    private boolean isHex(char c) {
        return c >= '0' && c <= '9' || c >= 'A' && c <= 'F';
    }

    private int toHex(char c) {
        if (c >= '0' && c <= '9') return c - '0';
        else return c - 'A' + 10;
    }

    private boolean refill() throws IOException {
        len = reader.read(buf);
        now = 0;
        return len > 0;
    }
}