///...................................*****.................................................///
///                  Mujahidul Islam ( mujahidulislam2923@gmail.com )                       ///
///                  Department of Ict                                                      ///
///                  Comilla University , Bangladesh.                                       ///
///...................................*****.................................................///

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

#define           CIN              ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define           ll               long long int
#define           ull              unsigned long long int
#define           pii              pair < int, int>
#define           pll              pair < ll, ll>
#define           MOD              1000000007
#define           vi               vector<int>
#define           vl               vector<ll>
#define           pb               push_back
#define           sc               scanf
#define           pf               printf
#define         scin(x)            scanf("%d",&(x))
#define        scin2(x,y)          scanf("%d %d",&(x),&(y))
#define         scln(x)            scanf("%lld",&(x))
#define        scln2(x,y)          scanf("%lld %lld",&(x),&(y))
#define       min3(a,b,c)          min(a,min(b,c))
#define       min4(a,b,c,d)        min(d,min(a,min(b,c)))
#define       max3(a,b,c)          max(a,max(b,c))
#define       max4(a,b,c,d)        max(d,max(a,max(b,c)))
#define         ms(a,b)            memset(a,b,sizeof(a))
#define           mp               make_pair
#define       gcd(a, b)            __gcd(a,b)
#define       lcm(a, b)            ((a)*(b)/gcd(a,b))
#define         input              freopen("input.txt","rt", stdin)
#define         output             freopen("output.txt","wt", stdout)
#define           PI               2*acos(0.0)
#define     rep( i , a , b )       for( i=a ; i<b ; i++)
#define     rev( i , a , b )       for( i=a ; i>=b ; i--)
#define     repx( i ,a,b, x)       for( i=a ; i<b ; i+=x)
#define       CASEL(t)             printf("Case %d:\n",t)
#define     RUN_CASE(t,T)          for(__typeof(t) t=1;t<=T;t++)

///priority_queue<int,vector<int>,greater<int> >pq;
///--------------Graph Moves--------------------------------------
///const int fx[] = {+1,-1,+0,+0};
///const int fy[] = {+0,+0,+1,-1};
///const int fx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's move
///const int fy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int fx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's move
///const int fy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's move
///---------------------------------------------------------------

int main()
{
    CIN;
    ll n,cnt=0,ck=0;
    cin>>n;
    string a,b;
    cin>>a>>b;
    a+='1';
    b+='1';

    for(int i=0; i<n; i++)
    {
        if(a[i]==b[i])
        {
            continue;
        }
        if(ck==1 && a[i]!=b[i])
        {
            ck=0;
            cnt++;
            continue;
        }

        if(a[i]!=b[i] && a[i+1]!=b[i+1])
        {
            if(a[i]==a[i+1])
            {
                if(i<=n-2 && a[i+2]!=b[i+2])
                {
                    if(a[i+1]==a[i+2])
                    {
                        cnt+=3;
                    }
                    else
                    {
                        cnt+=2;
                    }
                    i++;
                }
                else
                {
                    cnt+=2;
                }
            }
            else
                cnt++;
            i++;
        }
        else if(a[i]!=b[i] && a[i+1]==b[i+1])
        {
            cnt++;
            ck=1;
            i++;
        }
    }
    cout<<cnt<<endl;

    return 0;
}


///...................................*****.................................................///
///                  Mujahidul Islam ( mujahidulislam2923@gmail.com )                       ///
///                  Department of Ict                                                      ///
///                  Comilla University , Bangladesh.                                       ///
///...................................*****.................................................///

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

#define           CIN              ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define           ll               long long int
#define           ull              unsigned long long int
#define           pii              pair < int, int>
#define           pll              pair < ll, ll>
#define           MOD              1000000007
#define           vi               vector<int>
#define           vl               vector<ll>
#define           pb               push_back
#define           sc               scanf
#define           pf               printf
#define         scin(x)            scanf("%d",&(x))
#define        scin2(x,y)          scanf("%d %d",&(x),&(y))
#define         scln(x)            scanf("%lld",&(x))
#define        scln2(x,y)          scanf("%lld %lld",&(x),&(y))
#define       min3(a,b,c)          min(a,min(b,c))
#define       min4(a,b,c,d)        min(d,min(a,min(b,c)))
#define       max3(a,b,c)          max(a,max(b,c))
#define       max4(a,b,c,d)        max(d,max(a,max(b,c)))
#define         ms(a,b)            memset(a,b,sizeof(a))
#define           mp               make_pair
#define       gcd(a, b)            __gcd(a,b)
#define       lcm(a, b)            ((a)*(b)/gcd(a,b))
#define         input              freopen("input.txt","rt", stdin)
#define         output             freopen("output.txt","wt", stdout)
#define           PI               2*acos(0.0)
#define     rep( i , a , b )       for( i=a ; i<b ; i++)
#define     rev( i , a , b )       for( i=a ; i>=b ; i--)
#define     repx( i ,a,b, x)       for( i=a ; i<b ; i+=x)
#define       CASEL(t)             printf("Case %d:\n",t)
#define     RUN_CASE(t,T)          for(__typeof(t) t=1;t<=T;t++)

///priority_queue<int,vector<int>,greater<int> >pq;
///--------------Graph Moves--------------------------------------
///const int fx[] = {+1,-1,+0,+0};
///const int fy[] = {+0,+0,+1,-1};
///const int fx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's move
///const int fy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int fx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's move
///const int fy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's move
///---------------------------------------------------------------

int main()
{
    CIN;
    ll n,cnt=0,ck=0;
    cin>>n;
    string a,b;
    cin>>a>>b;
    a+='1';
    b+='1';

    for(int i=0; i<n; i++)
    {
        if(a[i]==b[i])
        {
            continue;
        }
        if(ck==1 && a[i]!=b[i])
        {
            ck=0;
            cnt++;
            continue;
        }

        if(a[i]!=b[i] && a[i+1]!=b[i+1])
        {
            if(a[i]==a[i+1])
            {
                if(i<=n-2 && a[i+2]!=b[i+2])
                {
                    cnt+=2;
                    i++;
                }
                else if(i<=n-2 && a[i+2]==b[i+2])
                {
                    cnt+=3;
                    i++;
                }
                else
                {
                    cnt+=2;
                }
            }
            else
                cnt++;
            i++;
        }
        else if(a[i]!=b[i] && a[i+1]==b[i+1])
        {
            cnt++;
            ck=1;
            i++;
        }
    }
    cout<<cnt<<endl;

    return 0;
}


///...................................*****.................................................///
///                  Mujahidul Islam ( mujahidulislam2923@gmail.com )                       ///
///                  Department of Ict                                                      ///
///                  Comilla University , Bangladesh.                                       ///
///...................................*****.................................................///

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

#define           CIN              ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define           ll               long long int
#define           ull              unsigned long long int
#define           pii              pair < int, int>
#define           pll              pair < ll, ll>
#define           MOD              1000000007
#define           vi               vector<int>
#define           vl               vector<ll>
#define           pb               push_back
#define           sc               scanf
#define           pf               printf
#define         scin(x)            scanf("%d",&(x))
#define        scin2(x,y)          scanf("%d %d",&(x),&(y))
#define         scln(x)            scanf("%lld",&(x))
#define        scln2(x,y)          scanf("%lld %lld",&(x),&(y))
#define       min3(a,b,c)          min(a,min(b,c))
#define       min4(a,b,c,d)        min(d,min(a,min(b,c)))
#define       max3(a,b,c)          max(a,max(b,c))
#define       max4(a,b,c,d)        max(d,max(a,max(b,c)))
#define         ms(a,b)            memset(a,b,sizeof(a))
#define           mp               make_pair
#define       gcd(a, b)            __gcd(a,b)
#define       lcm(a, b)            ((a)*(b)/gcd(a,b))
#define         input              freopen("input.txt","rt", stdin)
#define         output             freopen("output.txt","wt", stdout)
#define           PI               2*acos(0.0)
#define     rep( i , a , b )       for( i=a ; i<b ; i++)
#define     rev( i , a , b )       for( i=a ; i>=b ; i--)
#define     repx( i ,a,b, x)       for( i=a ; i<b ; i+=x)
#define       CASEL(t)             printf("Case %d:\n",t)
#define     RUN_CASE(t,T)          for(__typeof(t) t=1;t<=T;t++)

///priority_queue<int,vector<int>,greater<int> >pq;
///--------------Graph Moves--------------------------------------
///const int fx[] = {+1,-1,+0,+0};
///const int fy[] = {+0,+0,+1,-1};
///const int fx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's move
///const int fy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int fx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's move
///const int fy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's move
///---------------------------------------------------------------

int main()
{
    CIN;
    ll n,cnt=0,ck=0;
    cin>>n;
    string a,b;
    cin>>a>>b;
    a+='1';
    b+='1';

    for(int i=0;i<n;i++)
    {
        if(a[i]==b[i])
        {
            continue;
        }
        if(ck==1 && a[i]!=b[i])
        {
            ck=0;
            cnt++;
            continue;
        }
        if(a[i]!=b[i] && a[i+1]!=b[i+1])
        {
            if(a[i]==a[i+1])
                cnt+=2;
            else
                cnt++;
            i++;
        }
        else if(a[i]!=b[i] && a[i+1]==b[i+1])
        {
            cnt++;
            ck=1;
            i++;
        }
    }
    cout<<cnt<<endl;

    return 0;
}


///...................................*****.................................................///
///                  Mujahidul Islam ( mujahidulislam2923@gmail.com )                       ///
///                  Department of Ict                                                      ///
///                  Comilla University , Bangladesh.                                       ///
///...................................*****.................................................///

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

#define           CIN              ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define           ll               long long int
#define           ull              unsigned long long int
#define           pii              pair < int, int>
#define           pll              pair < ll, ll>
#define           MOD              1000000007
#define           vi               vector<int>
#define           vl               vector<ll>
#define           pb               push_back
#define           sc               scanf
#define           pf               printf
#define         scin(x)            scanf("%d",&(x))
#define        scin2(x,y)          scanf("%d %d",&(x),&(y))
#define         scln(x)            scanf("%lld",&(x))
#define        scln2(x,y)          scanf("%lld %lld",&(x),&(y))
#define       min3(a,b,c)          min(a,min(b,c))
#define       min4(a,b,c,d)        min(d,min(a,min(b,c)))
#define       max3(a,b,c)          max(a,max(b,c))
#define       max4(a,b,c,d)        max(d,max(a,max(b,c)))
#define         ms(a,b)            memset(a,b,sizeof(a))
#define           mp               make_pair
#define       gcd(a, b)            __gcd(a,b)
#define       lcm(a, b)            ((a)*(b)/gcd(a,b))
#define         input              freopen("input.txt","rt", stdin)
#define         output             freopen("output.txt","wt", stdout)
#define           PI               2*acos(0.0)
#define     rep( i , a , b )       for( i=a ; i<b ; i++)
#define     rev( i , a , b )       for( i=a ; i>=b ; i--)
#define     repx( i ,a,b, x)       for( i=a ; i<b ; i+=x)
#define       CASEL(t)             printf("Case %d:\n",t)
#define     RUN_CASE(t,T)          for(__typeof(t) t=1;t<=T;t++)

///priority_queue<int,vector<int>,greater<int> >pq;
///--------------Graph Moves--------------------------------------
///const int fx[] = {+1,-1,+0,+0};
///const int fy[] = {+0,+0,+1,-1};
///const int fx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's move
///const int fy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int fx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's move
///const int fy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's move
///---------------------------------------------------------------

int main()
{
    CIN;
    ll n,cnt=0,ck=0;
    cin>>n;
    string a,b;
    cin>>a>>b;

    char a1,b1;
    for(int i=0; i<n; i++)
    {
        if(a[i]==b[i])
        {
            ck=0;
            continue;
        }
        if(ck==1 && a[i]!=b[i])
        {
            if(a[i]==a1 && b[i]==b1)
            {
                cnt++;
            }
            else
            {
                ck=0;
            }
            continue;
        }

       if(ck==0 && a[i]!=b[i])
        {
            cnt++;
            ck=1;
            a1=a[i];
            b1=b[i];
        }
    }
    cout<<cnt<<endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
	ll n;
	cin>>n;
	string a, b;
	cin>>a>>b;
	vector<ll> ch;
	for(ll i=0;i<n;i++){
		if(a[i]!=b[i]){
			ch.push_back(i);
		}
	}
	ll count=0,it=0;

	while(ch.size()>0 && it<ch.size()-1){
		if((ch[it+1]-ch[it]==1)&&(a[ch[it]]!=a[ch[it+1]])){
			count++;
		else
			count+=2;
		it+=2;
	}
	if(it==ch.size()-1)
		count++;

	cout<<count<<endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
	ll n;
	cin>>n;
	string a, b;
	cin>>a>>b;
	vector<ll> ch;
	for(ll i=0;i<n;i++){
		if(a[i]!=b[i]){
			ch.push_back(i);
		}
	}
	ll count=0,it=0;

	while(ch.size()>0 && it<ch.size()-1){
		if((ch[it+1]-ch[it]==1)&&(a[ch[it]]!=a[ch[it+1]]))
			count++;
		else
			count+=2;
		it+=2;
	}
	if(it==ch.size()-1)
		count++;

	cout<<count<<endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	string a, b;
	cin>>a>>b;
	vector<int> ch;
	for(int i=0;i<n;i++){
		if(a[i]!=b[i]){
			ch.push_back(i);
		}
	}
	int count=0,it=0;

	while(ch.size()>0 && it<ch.size()-1){
		if(ch[it+1]-ch[it]==1){
			if(a[ch[it]]!=a[ch[it+1]]){
				//cout<<"near by and unequal "<<it<<" "<<ch[it] <<endl;
				count++;
			}
			else{
			    // cout<<"near by but equal "<<it<<" "<<ch[it]<<endl;
				count+=2;
			}
		}
		else{
		    // cout<<"seperate "<<ch[it]<<endl;
			count+=2;
		}
		it+=2;
	}
	if(it==ch.size()-1){
	    // cout<<"last elemet"<<endl;
		count++;
	}
	cout<<count<<endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	string a, b;
	cin>>a>>b;
	vector<int> ch;
	for(int i=0;i<n;i++){
		if(a[i]!=b[i]){
			ch.push_back(i);
		}
	}
	int count=0,it=0;

	while(ch.size()>0&&it<ch.size()-1){
		if(abs(ch[it+1]-ch[it])==1){
			count++;
		}
		else{
			count+=2;
		}
		it+=2;
	}
	if(it==ch.size()-1){
		count++;
	}
	cout<<count<<endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	string a, b;
	cin>>a>>b;
	vector<int> ch;
	for(int i=0;i<n;i++){
		if(a[i]!=b[i]){
			ch.push_back(i);
		}
	}
	int count=0,it=0;

	while(it<ch.size()-1){
		if(abs(ch[it+1]-ch[it])==1){
			count++;
		}
		else{
			count+=2;
		}
		it+=2;
	}
	if(it==ch.size()-1){
		count++;
	}
	cout<<count<<endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
	ll n;
	cin>>n;
	string a, b;
	cin>>a>>b;
	vector<ll> ch;
	for(ll i=0;i<n;i++){
		if(a[i]!=b[i]){
			ch.push_back(i);
		}
	}
	ll count=0,it=0;

	while(ch.size()>0 && it<ch.size()-1){
		if((ch[it+1]-ch[it]==1)&&(a[ch[it]]!=a[ch[it+1]])){
			it+=2;
			count++;
		}
		else{
			it++;
			count++;
		}
	}
	if(it==ch.size()-1)
		count++;

	cout<<count<<endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
	ll n;
	cin>>n;
	string a, b;
	cin>>a>>b;
	vector<ll> ch;
	for(ll i=0;i<n;i++){
		if(a[i]!=b[i]){
			ch.push_back(i);
		}
	}
	ll count=0,it=0;

	while(ch.size()>0 && it<ch.size()-1){
		if(ch[it+1]-ch[it]==1){
			if(a[ch[it]]!=a[ch[it+1]]){
				count++;
			}
			else{
				count+=2;
			}
		}
		else{
		    // cout<<"seperate "<<ch[it]<<endl;
			count+=2;
		}
		it+=2;
	}
	if(it==ch.size()-1){
	    // cout<<"last elemet"<<endl;
		count++;
	}
	cout<<count<<endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
	ll n;
	cin>>n;
	string a, b;
	cin>>a>>b;
	vector<ll> ch;
	for(ll i=0;i<n;i++){
		if(a[i]!=b[i]){
			ch.push_back(i);
		}
	}
	ll count=0,it=0;

	while(ch.size()>0 && it<ch.size()-1){
		if((ch[it+1]-ch[it]==1)&&(a[ch[it]]!=a[ch[it+1]])){
			it+=2;
			count++;
		}
		else{
			it++;
			count+=2;
		}
	}
	if(it==ch.size()-1)
		count++;

	cout<<count<<endl;

	return 0;
}


// @author PraveenKumarRana

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

#define pb push_back
#define mp make_pair
#define int long long int
#define vi vector<int>
#define pi pair<int, int>
#define IOS std::ios_base::sync_with_stdio(false);
#define all(x) x.begin(), x.end()

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

void SOLVE() {
    // Write your code here ?
    int n;
    cin >> n;
    string a, b;
    cin >> a >> b;

    map<int, int> aa, zz;
    vi bb, oo;
    int ans1 = 0, ans2;
    for (int i = 0; i < n; i++) {
        if (a[i] != b[i]) {
            if (a[i] == '1') {
                aa[i]++;
                zz[i]++;
            } else {
                bb.pb(i);
                oo.pb(i);
            }
            ans1++;
            ans2++;
        }
    }

    for (int i = 0; i < bb.size(); i++) {
        if (aa[bb[i] + 1] > 0) {
            ans1--;
            aa[bb[i] + 1]--;
        } else if (aa[bb[i] - 1] > 0) {
            ans1--;
            aa[bb[i] - 1]--;
        } else {
            continue;
        }
    }

    for (int i = 0; i < oo.size(); i++) {
        if (zz[oo[i] + 1] > 0) {
            ans2--;
            zz[oo[i] + 1]--;
        } else if (zz[oo[i] - 1] > 0) {
            ans2--;
            zz[oo[i] - 1]--;
        } else {
            continue;
        }
    }

    cout << min(ans1, ans2) << "\n";
}

int32_t main() {
    IOS

    SOLVE();

    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define MAX_LL 1e18+1
#define pll pair<ll,ll>
using namespace std;

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

    vector< pair<char,int> > op;
    for(int i=0; i<n; i++){
        if(a[i]!=b[i]) op.pb(mp(a[i],i));
    }

    int answer=0;
    for(int i=1; i<op.size(); i=i+2){
        if((op[i].second-op[i-1].second)==1 && op[i].first!=op[i-1].first) answer++;
        else answer+=2;
    }

    if(op.size()==1) cout<<1<<"\n";
    else cout<<answer<<"\n";
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


// @author PraveenKumarRana

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

#define pb push_back
#define mp make_pair
#define int long long int
#define vi vector<int>
#define pi pair<int, int>
#define IOS std::ios_base::sync_with_stdio(false);
#define all(x) x.begin(), x.end()

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

void SOLVE() {
    // Write your code here ?
    int n;
    cin >> n;
    string a, b;
    cin >> a >> b;

    map<int, int> aa;
    vi bb;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] != b[i]) {
            if (a[i] == '1') {
                aa[i]++;
            } else {
                bb.pb(i);
            }
            ans++;
        }
    }

    // cout << ans << "\n";
    for (int i = 0; i < bb.size(); i++) {
        // cout << "bb: " << bb[i] << endl;
        if (aa[bb[i] + 1]) {
            ans--;
            aa[bb[i] + 1]--;
        } else if (aa[bb[i] - 1]) {
            ans--;
            aa[bb[i] - 1]--;
        } else {
            continue;
        }
    }

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

int32_t main() {
    IOS

    SOLVE();

    return 0;
}


// @author PraveenKumarRana

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

#define pb push_back
#define mp make_pair
#define int long long int
#define vi vector<int>
#define pi pair<int, int>
#define IOS std::ios_base::sync_with_stdio(false);
#define all(x) x.begin(), x.end()

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

void SOLVE() {
    // Write your code here ?
    int n;
    cin >> n;
    string a, b;
    cin >> a >> b;

    int ans = 0;
    for (int i = 0; i < n - 1; i++) {
        if (a[i] == b[i + 1] && a[i + 1] == b[i] && a[i] != b[i]) {
            swap(a[i], a[i + 1]);
            ans++;
        }
    }

    for (int i = 0; i < n; i++) {
        if (a[i] != b[i]) {
            ans++;
        }
    }

    cout << ans << endl;
}

int32_t main() {
    IOS

    SOLVE();

    return 0;
}


// @author PraveenKumarRana

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

#define pb push_back
#define mp make_pair
#define int long long int
#define vi vector<int>
#define pi pair<int, int>
#define IOS std::ios_base::sync_with_stdio(false);
#define all(x) x.begin(), x.end()

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

void SOLVE() {
    // Write your code here ?
    int n;
    cin >> n;
    string a, b;
    cin >> a >> b;

    vi aa, bb;
    for (int i = 0; i < n; i++) {
        if (a[i] != b[i]) {
            if (a[i] != b[i]) {
                aa.pb(i);
            }
        }
    }

    vi diff(aa.size() - 1);
    for (int i = 1; i < aa.size(); i++) {
        diff[i - 1] = aa[i] - aa[i - 1];
    }

    bool ok = true;
    int ans = 0;
    for (int i = 0; i < diff.size(); i++) {
        if (ok && diff[i] == 1) {
            ans++;
            ok = false;
        } else if (diff[i] == 1) {
            continue;
        } else {
            ok = true;
        }
    }

    ans = ans + (aa.size() - 2 * ans);

    cout << ans << endl;
}

int32_t main() {
    IOS

    SOLVE();

    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define MAX_LL 1e18+1
#define pll pair<ll,ll>
using namespace std;

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

    vector< pair<char,int> > op;
    for(int i=0; i<n; i++){
        if(a[i]!=b[i]) op.pb(mp(a[i],i));
    }

    int answer=0;
    for(int i=1; i<op.size(); i=i+2){
        if((op[i].second-op[i-1].second)==1 && op[i].first!=op[i-1].first) answer++;
        else answer+=2;
    }

    if(op.size()%2!=0) answer++;

    if(op.size()==1) cout<<1<<"\n";
    else cout<<answer<<"\n";
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


// @author PraveenKumarRana

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

#define pb push_back
#define mp make_pair
#define int long long int
#define vi vector<int>
#define pi pair<int, int>
#define IOS std::ios_base::sync_with_stdio(false);
#define all(x) x.begin(), x.end()

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

void SOLVE() {
    // Write your code here ?
    int n;
    cin >> n;
    string a, b;
    cin >> a >> b;

    vi aa, bb;
    for (int i = 0; i < n; i++) {
        if (a[i] != b[i]) {
            if (a[i] == '1') {
                aa.pb(i);
            }
            if (b[i] == '1') {
                bb.pb(i);
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < aa.size(); i++) {
        // cout << aa[i] << " " << bb[i] << endl;
        ans = min(ans + abs(aa[i] - bb[i]), ans + 2);
    }

    cout << ans << endl;
}

int32_t main() {
    IOS

    SOLVE();

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define ff first
#define ss second

typedef long long ll;
typedef vector<long long> vll;

#define PI 3.141592653589793
#define N 200005

int main()
{
    IOS;
    ll n;
    cin>>n;
    string a,b;
    cin>>a>>b;
    set<ll> one,zero;
    for(ll i=0;i<n;i++)
    {
    	if(a[i]!=b[i])
    	{
    		if(a[i]=='1')
    			one.insert(i);
    		else
    			zero.insert(i);
    	}
    }
    one.insert(LONG_MAX);
    zero.insert(LONG_MAX);
    ll ans=0;
	for(ll i=0;i<n;i++)
	{
		if(a[i]!=b[i])
		{
			if(a[i]=='0')
			{
				auto it=lower_bound(one.begin(), one.end(),i);
				if(abs(*it-i)>1)
					ans++;
				else
				{
					ans+=*it-i;
					a[*it]='0';
					//one.erase(one.find(*it));
				}
				//zero.erase(zero.find(i));
			}
			else
			{
				auto it=lower_bound(zero.begin(), zero.end(),i);
				if(abs(*it-i)>1)
					ans++;
				else
				{
					ans+=*it-i;
					a[*it]='1';
					//zero.erase(zero.find(*it));
				}
				//one.erase(one.find(i));
			}

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


#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define ff first
#define ss second

typedef long long ll;
typedef vector<long long> vll;

#define PI 3.141592653589793
#define N 200005

int main()
{
    IOS;
    ll n;
    cin>>n;
    string a,b;
    cin>>a>>b;
    vll v;
    for(ll i=0;i<n;i++)
    {
    	if(a[i]!=b[i])
    		v.pb(i);
    }
    vll one,zero;
    for(ll i=0;i<v.size();i++)
    {
    	if(a[v[i]]=='0')
    		one.pb(v[i]);
    	else
    		zero.pb(v[i]);
    }
    sort(one.begin(),one.end());
    sort(zero.begin(),zero.end());
    ll ans=0;
    ll used=0;
    for(ll i=0;i<one.size();i++)
    {
    	vector<long long>::iterator lower;
    	lower=upper_bound(zero.begin(),zero.end(),one[i]);
    	ll v1=LONG_MAX,v2=LONG_MAX;
    	if(lower!=zero.end())
    		v1=abs(*lower - one[i]);
    	//cout<<lower-zero.begin()<<endl;
    	if(lower!=zero.begin())
    	{
    		lower--;
    		v2=abs(*lower - one[i]);
    	}
    	ll val=min(v1,v2);
    	if(val<=2)
    	{
    		ans+=val;
    		used++;
    	}
    	else
    	{
    		ans++;
    	}
    }
    //cout<<ans<<endl;
    ans+=abs(zero.size()-used);
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define ff first
#define ss second

typedef long long ll;
typedef vector<long long> vll;

#define PI 3.141592653589793
#define N 200005

int main()
{
    IOS;
    ll n;
    cin>>n;
    string a,b;
    cin>>a>>b;
    vll v;
    for(ll i=0;i<n;i++)
    {
    	if(a[i]!=b[i])
    		v.pb(i);
    }
    vll one,zero;
    for(ll i=0;i<v.size();i++)
    {
    	if(a[v[i]]=='0')
    		one.pb(v[i]);
    	else
    		zero.pb(v[i]);
    }
    sort(one.begin(),one.end());
    sort(zero.begin(),zero.end());
    ll ans=0;
    ll used=0;
    for(ll i=0;i<one.size();i++)
    {
    	vector<long long>::iterator lower;
    	lower=upper_bound(zero.begin(),zero.end(),one[i]);
    	ll v1=LONG_MAX,v2=LONG_MAX;
    	v1=abs(*lower - one[i]);
    	//cout<<lower-zero.begin()<<endl;
    	if(lower!=zero.begin())
    	{
    		lower--;
    		v2=abs(*lower - one[i]);
    	}
    	ll val=min(v1,v2);
    	if(val<=2)
    	{
    		ans+=val;
    		used++;
    	}
    	else
    	{
    		ans++;
    	}
    }
    //cout<<ans<<endl;
    ans+=abs(zero.size()-used);
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define ff first
#define ss second

typedef long long ll;
typedef vector<long long> vll;

#define PI 3.141592653589793
#define N 200005

int main()
{
    IOS;
    ll n;
    cin>>n;
    string a,b;
    cin>>a>>b;
    vll one,zero;
    for(ll i=0;i<n;i++)
    {
    	if(a[i]!=b[i])
    	{
    		if(a[i]=='1')
    			one.pb(i);
    		else
    			zero.pb(i);
    	}
    }
    one.pb(LONG_MAX);
    zero.pb(LONG_MAX);
    ll ans=0;
	for(ll i=0;i<n;i++)
	{
		if(a[i]!=b[i])
		{
			if(a[i]=='0')
			{
				auto it=lower_bound(one.begin(), one.end(),i);
				if(abs(*it-i)>1)
					ans++;
				else
				{
					ans+=*it-i;
					a[*it]='0';
					//one.erase(one.find(*it));
				}
				//zero.erase(zero.find(i));
			}
			else
			{
				auto it=lower_bound(zero.begin(), zero.end(),i);
				if(abs(*it-i)>1)
					ans++;
				else
				{
					ans+=*it-i;
					a[*it]='1';
					//zero.erase(zero.find(*it));
				}
				//one.erase(one.find(i));
			}

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


#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define ff first
#define ss second

typedef long long ll;
typedef vector<long long> vll;

#define PI 3.141592653589793
#define N 200005

int main()
{
    IOS;
    ll n;
    cin>>n;
    string a,b;
    cin>>a>>b;
    set<ll> one,zero;
    for(ll i=0;i<n;i++)
    {
    	if(a[i]!=b[i])
    	{
    		if(a[i]=='1')
    			one.insert(i);
    		else
    			zero.insert(i);
    	}
    }
    one.insert(LONG_MAX);
    zero.insert(LONG_MAX);
    ll ans=0;
	for(ll i=0;i<n;i++)
	{
		if(a[i]!=b[i])
		{
			if(a[i]=='0')
			{
				auto it=lower_bound(one.begin(), one.end(),i);
				if(abs(*it-i)>1)
					ans++;
				else
				{
					ans+=*it-i;
					a[*it]='0';
					one.erase(one.find(*it));
				}
				zero.erase(zero.find(i));
			}
			else
			{
				auto it=lower_bound(zero.begin(), zero.end(),i);
				if(abs(*it-i)>1)
					ans++;
				else
				{
					ans+=*it-i;
					a[*it]='1';
					zero.erase(zero.find(*it));
				}
				one.erase(one.find(i));
			}

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


#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define ff first
#define ss second

typedef long long ll;
typedef vector<long long> vll;

#define PI 3.141592653589793
#define N 200005

int main()
{
    IOS;
    ll n;
    cin>>n;
    string a,b;
    cin>>a>>b;
    vll v;
    for(ll i=0;i<n;i++)
    {
    	if(a[i]!=b[i])
    		v.pb(i);
    }
    vll one,zero;
    for(ll i=0;i<v.size();i++)
    {
    	if(a[v[i]]=='0')
    		one.pb(v[i]);
    	else
    		zero.pb(v[i]);
    }
    sort(one.begin(),one.end());
    sort(zero.begin(),zero.end());
    ll ans=0;
    ll used=0;
    for(ll i=0;i<one.size();i++)
    {
    	vector<long long>::iterator lower;
    	lower=upper_bound(zero.begin(),zero.end(),one[i]);
    	ll v1=LONG_MAX,v2=LONG_MAX,v3=LONG_MAX;
    	if(lower!=zero.end())
    		v1=abs(*lower - one[i]);
    	//cout<<lower-zero.begin()<<endl;
    	if(lower!=zero.begin())
    	{
    		lower--;
    		v2=abs(*lower - one[i]);
    	}
    	if(lower!=zero.begin())
    	{
    		lower--;
    		v3=abs(*lower - one[i]);
    	}
    	ll val=min(v1,min(v2,v3));
    	if(val<=2)
    	{
    		ans+=val;
    		used++;
    	}
    	else
    	{
    		ans++;
    	}
    }
    //cout<<ans<<endl;
    ans+=abs(zero.size()-used);
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main(){

    int n;
    cin>>n;

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

    int cost=0;

    for(int i=0;i<n;){

        if(s1[i]==s2[i]){
            i++;
        }

        if(s1[i+1]!=s2[i+1]){
            cost+=1;
            i=i+2;
        }else{
            cost+=1;
            i++;
        }
    }

    cout<<cost<<endl;

return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main(){

    int n;
    cin>>n;

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

    int cost=0;

    for(int i=0;i<n;i++){

        if(s1[i]==s2[i]){
            continue;
        }

        if(s1[i+1]!=s2[i+1]){
            cost+=1;
            i=i+2;
        }else{
            cost+=1;
        }
    }

    cout<<cost<<endl;

return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin>>n;
    string a,b;

    cin>>a>>b;

    int cost=0,i=0;

    while(i<n){

        if(a[i]!=b[i]){

            if(a[i+1]!=b[i+1]&&a[i+1]!=a[i]){
                swap(a[i],a[i+1]);
                cost++;
                i+=2;
            }
            else{
            if(a[i]==0)
                a[i]=1;
            else a[i]=0;
            cost++;
            i++;
            }
        }
        else i++;
    }

    cout<<cost<<endl;

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main(){

    int n;
    cin>>n;

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

    int cost=0;

    for(int i=0;i<n;){

        if(s1[i]==s2[i]){
            i++;
        }else{

        if(s1[i]!=s1[i+1]&&s1[i+1]!=s2[i+1]){
            cost+=1;
            i=i+2;
        }else{
            cost+=1;
            i++;
        }
        }
    }

    cout<<cost<<endl;

return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main(){

    int n;
    cin>>n;

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

    int cost=0;

    for(int i=0;i<n;){

        if(s1[i]==s2[i]){
            i++;
        }else{

        if(s1[i+1]!=s2[i+1]){
            cost+=1;
            i=i+2;
        }else{
            cost+=1;
            i++;
        }
        }
    }

    cout<<cost<<endl;

return 0;
}


#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define MOD 1000000007
#define mod 998244353
#define pie 3.14159265358979323846264338327950L
#define N 200009
#define M 2000009
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define umap unordered_map<int, int>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define endl "\n"
#define int long long
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}

int n;
int arr[30];
bool check;

void test_case() {

    int n;
    cin>>n;

    string s,t;
    cin>>s>>t;

    int ans = 0;

    unordered_set<int> ind;
    vec temp;
    for(int i=0; i<n; i++) {
        if(s[i] != t[i]) {
            ind.insert(i);
            temp.pb(i);
        }
    }

    for(auto i = 0; i<temp.size(); i++) {
        int it = temp[i];
       //  cout<<it<<endl;
        if(find(all(ind),it+1) != ind.end() && s[it] == t[it+1] && t[it] == s[it+1]) {
            ans++;
            i++;
        } else {
            ans++;
        }
    }

    cout<<ans<<endl;

}

signed main ()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(20);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

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


#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define MOD 1000000007
#define mod 998244353
#define pie 3.14159265358979323846264338327950L
#define N 200009
#define M 2000009
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define umap unordered_map<int, int>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define endl "\n"
#define int long long
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}

int n;
int arr[30];
bool check;

int arr[1000008];

void test_case() {

    int n;
    cin>>n;

    string s,t;
    cin>>s>>t;

    int ans = 0;

   //  unordered_set<int> ind;
    vec temp;
    for(int i=0; i<n; i++) {
        if(s[i] != t[i]) {
            arr[i] = 1;
            temp.pb(i);
        }
    }

    for(auto i = 0; i<temp.size(); i++) {
        int it = temp[i];
       //  cout<<it<<endl;
        if(arr[it+1] == 1 && s[it] == t[it+1] && t[it] == s[it+1]) {
            ans++;
            i++;
        } else {
            ans++;
        }
    }

    cout<<ans<<endl;

}

signed main ()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(20);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

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


#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define MOD 1000000007
#define mod 998244353
#define pie 3.14159265358979323846264338327950L
#define N 200009
#define M 2000009
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define umap unordered_map<int, int>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define endl "\n"
#define int long long
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}

int n;
int arr[30];
bool check;

void test_case() {

    int n;
    cin>>n;

    string s,t;
    cin>>s>>t;

    int ans = 0;

    vec ind;
    for(int i=0; i<n; i++) {
        if(s[i] != t[i]) {
            ind.pb(i);
        }
    }

    for(int i=0; i<ind.size(); i++) {
        int it = ind[i];
        if(find(all(ind),it+1) != ind.end() && s[it] == t[it+1] && t[it] == s[it+1]) {
            ans++;
            i++;
        } else {
            ans++;
        }
    }

    cout<<ans<<endl;

}

signed main ()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(20);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

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


#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define MOD 1000000007
#define mod 998244353
#define pie 3.14159265358979323846264338327950L
#define N 200009
#define M 2000009
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define umap unordered_map<int, int>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define endl "\n"
#define int long long
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}

int n;
int arr[30];
bool check;

void test_case() {

    int n;
    cin>>n;

    string s,t;
    cin>>s>>t;

    int ans = 0;

    unordered_set<int> ind;
    for(int i=0; i<n; i++) {
        if(s[i] != t[i]) {
            ind.insert(i);
        }
    }

    for(auto i = ind.begin(); i != ind.end(); i++) {
        int it = *i;
        if(find(all(ind),it+1) != ind.end() && s[it] == t[it+1] && t[it] == s[it+1]) {
            ans++;
            i++;
            if(i == ind. end()) {
                break;
            }
        } else {
            ans++;
        }
    }

    cout<<ans<<endl;

}

signed main ()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(20);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

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


#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define MOD 1000000007
#define mod 998244353
#define pie 3.14159265358979323846264338327950L
#define N 200009
#define M 2000009
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define umap unordered_map<int, int>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define endl "\n"
#define int long long
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}

int n;
int arr[30];
bool check;

void test_case() {

    int n;
    cin>>n;

    string s,t;
    cin>>s>>t;

    int ans = 0;

    vec ind;
    for(int i=0; i<n; i++) {
        if(s[i] != t[i]) {
            ind.pb(i);
        }
    }

    for(int i=0; i<ind.size(); i++) {
        int it = ind[i];
        if(find(all(ind),it+1) != ind.end()) {
            ans++;
            i++;
        } else {
            ans++;
        }
    }

    cout<<ans<<endl;

}

signed main ()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(20);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

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


#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define MOD 1000000007
#define mod 998244353
#define pie 3.14159265358979323846264338327950L
#define N 200009
#define M 2000009
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define umap unordered_map<int, int>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define endl "\n"
#define int long long
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}

int n;
int arr[30];
bool check;

void test_case() {

    int n;
    cin>>n;

    string s,t;
    cin>>s>>t;

    int ans = 0;

    set<int> ind;
    for(int i=0; i<n; i++) {
        if(s[i] != t[i]) {
            ind.insert(i);
        }
    }

    for(auto i = ind.begin(); i != ind.end(); i++) {
        int it = *i;
        if(find(all(ind),it+1) != ind.end() && s[it] == t[it+1] && t[it] == s[it+1]) {
            ans++;
            i++;
            if(i == ind. end()) {
                break;
            }
        } else {
            ans++;
        }
    }

    cout<<ans<<endl;

}

signed main ()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(20);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

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


#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define MOD 1000000007
#define mod 998244353
#define pie 3.14159265358979323846264338327950L
#define N 200009
#define M 2000009
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define umap unordered_map<int, int>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define endl "\n"
#define int long long
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}

int arr[1000008];

void test_case() {

    int n;
    cin>>n;

    string s,t;
    cin>>s>>t;

    int ans = 0;

   //  unordered_set<int> ind;
    vec temp;
    for(int i=0; i<n; i++) {
        if(s[i] != t[i]) {
            arr[i] = 1;
            temp.pb(i);
        }
    }

    for(auto i = 0; i<temp.size(); i++) {
        int it = temp[i];
       //  cout<<it<<endl;
        if(arr[it+1] == 1 && s[it] == t[it+1] && t[it] == s[it+1]) {
            ans++;
            i++;
        } else {
            ans++;
        }
    }

    cout<<ans<<endl;

}

signed main ()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(20);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

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


#include <iostream>
#include <algorithm>
#include <string>
#include<vector>
using namespace std;

int main()
{
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int n;
	string a, b;
	cin >> n;
	cin >> a >> b;
	//if (a == b)
	//{
	//	cout << 0 << endl;
	//	return 0;
	//}
	vector<int> k;
	for (int i = 0; i < n; i++)
	{
		if (a[i] != b[i])
			k.push_back(i);
	}
	int cnt = 0;
	int kl = k.size();
	for (int i = 0; i < kl - 1; i++)
	{
		if (k[i] + 1 == k[i + 1] && a[k[i]] != a[k[i + 1]])
		{
			++cnt;
			++i;
		}
	}
	cout << k.size() - cnt << endl;
	k.clear();
	//system("pause");
	return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <set>
using namespace std;

vector<int> k;

int main()
{
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	string a, b;
	int n;
	cin >> n;
	cin >> a >> b;
	int cnt = 0;
	for (int i = 0; i < n; i++)
	{
		if (a[i] != b[i])
			k.push_back(i);
	}
	for (int i = 0; i < k.size() - 1; i++)
		if (k[i] + 1 == k[i + 1])
			++cnt;
	cout << k.size() - cnt << endl;
	k.clear();
	//system("pause");
	return 0;
}


#include <iostream>
#include <algorithm>
#include <string>
#include<vector>
using namespace std;

int main()
{
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int n;
	string a, b;
	cin >> n;
	cin >> a >> b;
	if (a == b)
	{
		cout << 0 << endl;
		return 0;
	}
	vector<int> k;
	for (int i = 0; i < n; i++)
	{
		if (a[i] != b[i])
			k.push_back(i);
	}
	int cnt = 0;
	for (int i = 0; i < k.size() - 1; i++)
	{
		if (k[i] + 1 == k[i + 1] && a[k[i]] != a[k[i + 1]])
		{
			++cnt;
			++i;
		}
	}
	cout << k.size() - cnt << endl;
	k.clear();
	//system("pause");
	return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <set>
using namespace std;

vector<int> k;
vector<char> ch;

int main()
{
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	string a, b;
	int n;
	cin >> n;
	cin >> a >> b;
	int cnt = 0;
	for (int i = 0; i < n; i++)
	{
		if (a[i] != b[i])
			k.push_back(i);
	}
	for (int i = 0; i < k.size() - 1; i++)
		if (k[i] + 1 == k[i + 1] && a[i] != a[i + 1])
		{
			++cnt;
			++i;
		}
	cout << k.size() - cnt << endl;
	k.clear();
	//system("pause");
	return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <set>
using namespace std;

vector<int> k;
vector<char> ch;

int main()
{
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	string a, b;
	int n;
	cin >> n;
	cin >> a >> b;
	int cnt = 0;
	for (int i = 0; i < n; i++)
	{
		if (a[i] != b[i])
			k.push_back(i);
	}
	for (int i = 0; i < k.size() - 1; i++)
	{
		if (k[i] + 1 == k[i + 1] && a[k[i]] != a[k[i + 1]])
		{
			++cnt;
			++i;
		}
	}
	cout << k.size() - cnt << endl;
	k.clear();
	//system("pause");
	return 0;
}


#include <iostream>
#include <algorithm>
#include <string>
#include<vector>
using namespace std;

int main()
{
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int n;
	string a, b;
	cin >> n;
	cin >> a >> b;
	if (a == b)
	{
		cout << 0 << endl;
		return 0;
	}
	vector<int> k;
	for (int i = 0; i < n; i++)
	{
		if (a[i] != b[i])
			k.push_back(i);
	}
	int cnt = 0;
	for (int i = 0; i < k.size() - 1; i++)
	{
		if (k[i] + 1 == k[i + 1] && a[k[i]] != a[k[i + 1]])
		{
			++cnt;
			++i;
		}
	}
	cout << k.size() - cnt << endl;
	k.clear();
	system("pause");
	return 0;
}


#include <iostream>
#include <algorithm>
#include <string>
#include<vector>
using namespace std;

int main()
{
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int n;
	string a, b;
	cin >> n;
	cin >> a >> b;
	vector<int> k;
	for (int i = 0; i < n; i++)
	{
		if (a[i] != b[i])
			k.push_back(i);
	}
	int cnt = 0;
	for (int i = 0; i < k.size() - 1; i++)
	{
		if (k[i] + 1 == k[i + 1] && a[k[i]] != a[k[i + 1]])
		{
			++cnt;
			++i;
		}
	}
	cout << k.size() - cnt << endl;
	k.clear();
	//system("pause");
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>

using namespace std;

int main(){

    //Equalize

    int n;

    cin>>n;

    string a, b;

    cin>>a>>b;

    int i, idx[n], c=0;

    for (i=0;i<n;i++){
        if (a[i]!=b[i]){
            idx[c]=i;
            c++;
        }
    }

    int ans=0;

    for (i=1;i<c;i+=2){
        if (idx[i]-idx[i-1]==1){
            if (a[idx[i]]==a[idx[i-1]]){
                ans+=2;
            }
            else {
                ans++;
            }
        }
        else {
            ans+=2;
        }
    }

    ans+=(c%2);

    cout<<ans<<'\n';

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t;cin>>t;
    for(int i=0;i<t;i++)
    {
        long long int A[2];
        cin >> A[0] >> A[1];
        sort(A,A+2);
        long long int a,b;
        cin >> a >> b;
        if((2*a)<b)
        {
            cout << (A[1]+A[0])*a << "\n";
        }
        else
        {
            cout << (A[1]-A[0])*a + A[0]*b << "\n" ;
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t;cin>>t;
    for(int i=0;i<t;i++)
    {
        long long int A[2];
        cin >> A[0] >> A[1];
        sort(A,A+2);
        long long int a,b;
        cin >> a >> b;
        int ans= (A[1]-A[0])*a;
        if((2*a)<b)
        {
            cout << ans + (A[0])*2*a  << "\n";
        }
        else
        {
            cout << ans + A[0]*b << "\n" ;
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t;cin>>t;
    for(int i=0;i<t;i++)
    {
        long long int A[2];
        cin >> A[0] >> A[1];
        sort(A,A+2);
        long long int a,b;
        cin >> a >> b;

        if( A[0]==0 && A[1]==0 )
        {
            cout << 0 << "\n";
        }
        else
        {

            int ans= (A[1]-A[0])*a;
            if((2*a)<b)
            {
                cout << ans + (A[0])*2*a  << "\n";
            }
            else
            {
                cout << ans + A[0]*b << "\n" ;
            }
        }
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t;cin>>t;
    for(int i=0;i<t;i++)
    {
        int A[2];
        cin >> A[0] >> A[1];
        sort(A,A+2);
        int a,b;
        cin >> a >> b;

        if( A[0]==0 && A[1]==0 )
        {
            cout << 0 << "\n";
        }
        else
        {

            int ans= (A[1]-A[0])*a;
            if((2*a)<b)
            {
                cout << ans + (A[0])*2*a  << "\n";
            }
            else
            {
                cout << ans + A[0]*b << "\n" ;
            }
        }
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    for(int i=0;i<t;i++){
        long long x,y,a,b;

        cin>>x>>y;
        cin>>a>>b;
        long long o=min(x,y);
        cout<<b*o+a*(max(x,y)-o)<<'\n';

    }
    return 0;
}


include <bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    for(int i=0;i<t;i++){
        long long x,y,a,b;

        cin>>x>>y;
        cin>>a>>b;
        long long o=min(x,y);
        cout<<b*o+a*(max(x,y)-o)<<'\n';

    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    for(int i=0;i<t;i++){
        long long int x,y,a,b;

        cin>>x>>y;
        cin>>a>>b;
        long long int o=min(x,y);
        cout<<b*o+a*(max(x,y)-o)<<'\n';

    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    for(int i=0;i<t;i++){
        unsigned long long int x,y,a,b;

        cin>>x>>y;
        cin>>a>>b;
        unsigned long long int o=min(x,y);
        cout<<(unsigned long long int) b*o+a*(max(x,y)-o)<<'\n';

    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    for(int i=0;i<t;i++){
        long long int x,y,a,b;

        cin>>x>>y;
        cin>>a>>b;
        long long int o=min(x,y);
        cout<<(long long int) b*o+a*(max(x,y)-o)<<'\n';

    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    for(int i=0;i<t;i++){
        unsigned long long int x,y,a,b;

        cin>>x>>y;
        cin>>a>>b;
        unsigned long long int o=min(x,y);
        cout<<(unsigned long long int) b*o+a*(max(x,y)-o)<<'/n';

    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    for(int i=0;i<t;i++){
        unsigned long long int x,y,a,b;

        cin>>x>>y;
        cin>>a>>b;
        unsigned long long int o=min(x,y);
        b=min(b,a+a);
        cout<<(unsigned long long int) b*o+a*(max(x,y)-o)<<'\n';

    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    for(int i=0;i<t;i++){
        int x,y,a,b;

        cin>>x>>y;
        cin>>a>>b;
        int o=min(x,y);
        cout<<b*o+a*(max(x,y)-o)<<'\n';

    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(){

	long long t;
	cin >> t;
	while(t--){
		long long x,y,a,b;
		cin >> x >> y >> a >> b;
		long long cost = 0;

	if(x==0&&y==0){

	}
	else{
		if(x<y){
			swap(x,y);
			}

			if(2*a<b){
				cost = x*a + y*a;
			}
			else{
			cost = (x-y)*a+y*b;
			}
	}

	cout << cost << "\n";
	}

}


#include <bits/stdc++.h>

using namespace std;

int main(){

	long long t;
	cin >> t;
	while(t--){
		long long x,y,a,b;
		cin >> x >> y >> a >> b;
		long long cost = 0;
	if(x>0){
			if(x<y){
			swap(x,y);
		}

		if(2*a<b){
		cost = (x-1)*a +b;
		}
		else{
		cost = (x-y)*a+y*b;
		}

	}

	cout << cost << "\n";
	}

}


#include <bits/stdc++.h>

using namespace std;

int main(){

	int t;
	cin >> t;
	while(t--){
		int x,y,a,b;
		cin >> x >> y >> a >> b;
		long long cost = 0;
	if(x>y){
		cost = (x-y)*a+y*b;
	}
	else{
		cost = (y-x)*a + x*b;
	}

	cout << cost << "\n";
	}

}


#include <bits/stdc++.h>

using namespace std;

int main(){

	long long t;
	cin >> t;
	while(t--){
		long long x,y,a,b;
	cin >> x >> y;
	cin >> a >> b;
	long long cost = 0;

	while(x!=y){
		if(x>y){
			x--;
			cost+=a;
		}
		if(y>x){
			y--;
			cost+=a;
		}
	}

	while(x=y &&x!=0){
		y--;
		x--;
		cost +=b;
	}
	cout << cost << "\n";
	}

}


#include <bits/stdc++.h>

using namespace std;

int main(){

	int t;
	cin >> t;
	while(t--){
		int x,y,a,b;
	cin >> x >> y >> a >> b;
	long long cost = 0;

	while(x!=y){
		if(x>y){
			x--;
			cost+=a;
		}
		if(y>x){
			y--;
			cost+=a;
		}
	}

	while(x=y &&x!=0){
		y--;
		x--;
		cost +=b;
	}
	cout << cost << "\n";
	}

}


#include <bits/stdc++.h>

using namespace std;

int main(){

	long long t;
	cin >> t;
	while(t--){
	}
	long long x,y,a,b;
	cin >> x >> y;
	cin >> a >> b;
	long long cost = 0;

	while(x!=y){
		if(x>y){
			x--;
			cost+=a;
		}
		if(y>x){
			y--;
			cost+=a;
		}
	}

	while(x=y &&x!=0){
		y--;
		x--;
		cost +=b;
	}
	cout << cost;

}


#include <bits/stdc++.h>

using namespace std;

int main(){

	long long t;
	cin >> t;
	while(t--){
		long long x,y,a,b;
		cin >> x >> y >> a >> b;
		long long cost = 0;

	if(x>0&&y>0){
			if(x<y){
			swap(x,y);
			}

		if(2*a<b){
		cost = x*a + y*a;
		}
		else{
		cost = (x-y)*a+y*b;
		}

	}

	cout << cost << "\n";
	}

}


#include <bits/stdc++.h>

using namespace std;

int main(){

	long long t;
	cin >> t;
	while(t--){
		long long x,y,a,b;
	cin >> x >> y >> a >> b;
	long long cost = 0;

	while(x!=y){
		if(x>y){
			x--;
			cost+=a;
		}
		if(y>x){
			y--;
			cost+=a;
		}
	}

	while(x=y &&x!=0){
		y--;
		x--;
		cost +=b;
	}
	cout << cost << "\n";
	}

}


#include <bits/stdc++.h>

using namespace std;

int main(){

	long long t;
	cin >> t;
	while(t--){
		long long x,y,a,b;
		cin >> x >> y >> a >> b;
		long long cost = 0;

	if(x<y){
		swap(x,y);
	}

	if(2*a<b){
		cost = (x-1)*a +b;
	}
	else{
		cost = (x-y)*a+y*b;
	}

	cout << cost << "\n";
	}

}


#include <bits/stdc++.h>

using namespace std;

int main(){

	long long t;
	cin >> t;
	while(t--){
		long long x,y,a,b;
		cin >> x >> y >> a >> b;
		long long cost = 0;
	if(x>y){
		cost = (x-y)*a+y*b;
	}
	else{
		cost = (y-x)*a + x*b;
	}

	cout << cost << "\n";
	}

}


#include <bits/stdc++.h>

using namespace std;

int main(){

	long long t;
	cin >> t;
	while(t--){
		long long x,y,a,b;
		cin >> x >> y >> a >> b;
		long long cost = 0;

	if(x>0){
			if(x<y){
			swap(x,y);
			}

		if(2*a<b){
		cost = x*a + y*a;
		}
		else{
		cost = (x-y)*a+y*b;
		}

	}

	cout << cost << "\n";
	}

}


#include <bits/stdc++.h>

using namespace std;

int main(){

	long long x,y,a,b;
	cin >> x >> y;
	cin >> a >> b;
	long long cost = 0;

	while(x!=y){
		if(x>y){
			x--;
			cost+=a;
		}
		if(y>x){
			y--;
			cost+=a;
		}
	}

	while(x=y &&x!=0){
		y--;
		x--;
		cost +=b;
	}
	cout << cost;

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		long int x,y,a,b;
		cin>>x>>y>>a>>b;
		long int M=max(x,y);
		long int m=min(x,y);
		unsigned long long dollars=0;
		if(b<2*a)
		dollars=a*abs(x-y)+min(x,y)*b;
		else
		dollars=(x+y)*a;
		cout<<dollars<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		long int x,y,a,b;
		cin>>x>>y>>a>>b;
		if(b<2*a)
		cout<<(min(x,y)*b+abs(y-x)*a)<<endl;
		else
		cout<<(x+y)*a<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		long int x,y,a,b;
		cin>>x>>y>>a>>b;
		long int M=max(x,y);
		long int m=min(x,y);
		if(b<2*a)
		cout<<a*M+min((b-a)*m,(b+a)*M)<<endl;
		else
		cout<<(x+y)*a<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		long long int x,y,a,b;
		cin>>x>>y>>a>>b;
		long long dollars=0;
		if(b<2*a)
		dollars+=a*abs(x-y)+min(x,y)*b;
		else
		dollars+=(x+y)*a;
		cout<<dollars<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		long int x,y,a,b;
		cin>>x>>y>>a>>b;
		long int M=max(x,y);
		long int m=min(x,y);
		unsigned long long int dollars=0;
		if(b<2*a)
			dollars=a*M+min(abs(b-a)*m,(b+a)*M);
		else
		dollars=(x+y)*a;
		cout<<dollars<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		long int x,y,a,b;
		cin>>x>>y>>a>>b;
		long int dollars=0;
		if(b<2*a)
			dollars+=(min(x,y)*b+abs(y-x)*a);
		else
		dollars+=(x+y)*a;
		cout<<dollars<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		long int x,y,a,b;
		cin>>x>>y>>a>>b;
		long int M=max(x,y);
		long int m=min(x,y);
		long long int dollars=0;
		if(b<2*a)
		dollars=a*M+min((b-a)*m,(b+a)*M);
		else
		dollars=(x+y)*a;
		cout<<dollars<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{

	    long long x,y;
	    cin>>x>>y;
	    long long a,b;
	    cin>>a>>b;
	    long long ans=0;
	            long long temp=abs(x-y);
	            ans+=temp*a;
	            long long temp3=min(x,y);
	            if(2*a<b)
	            ans+=temp3*a*2;
	            else
	            ans+=temp3*b;
	            cout<<ans<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		long int x,y,a,b;
		cin>>x>>y>>a>>b;
		long int M=max(x,y);
		long int m=min(x,y);
		unsigned long long dollars=0;
		if(b<2*a)
		dollars=a*M+(b-a)*m;
		else
		dollars=(x+y)*a;
		cout<<dollars<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		long int x,y,a,b;
		cin>>x>>y>>a>>b;
		long int M=max(x,y);
		long int m=min(x,y);
		long long int dollars=0;
		if(b<2*a)
			dollars=a*M+min(abs(b-a)*m,(b+a)*M);
		else
		dollars=(x+y)*a;
		cout<<dollars<<endl;
	}
	return 0;
}


#include <iostream>

using namespace std;

int main()
{
    unsigned long long n,a,b,x,y,ac,bc,z;
    cin >> n;
    for(unsigned long long i=0;i<n;i++)
    {
        ac=0,bc=0;
        cin >> x >> y >> a >> b;
        if(x>0 && y>0)
        {
            if(2*a<b)
            {
                while(x!=0 && y!=0)
                {
                    x--;
                    y--;
                    ac=ac+2;
                }
            }
            else
            {
                while(x!=0 && y!=0)
                {
                    x--;
                    y--;
                    bc=bc+1;
                }
            }
        }
        if(x>0)
        {
            while(x!=0)
            {
                x--;
                ac=ac+1;
            }
        }
        if(y>0)
        {
            while(y!=0)
            {
                y--;
                ac=ac+1;
            }
        }
        cout << ac*a+bc*b << endl;
    }
}


#include <iostream>

using namespace std;

int main()
{
    long long n,a,b,x,y;
    long long c=0;
    cin >> n;
    for(long long i=n;i--;)
    {
        c=0;
        cin >> x >> y >> a >> b;
        if(x>0 && y>0)
        {
            if(2*a<b)
            {
                if(x>y)
                {
                    c+=2*a*y;
                    x=x-y;
                    y=0;
                }
                else
                {
                    c+=2*a*x;
                    y=y-x;
                    x=0;
                }
            }
            else
            {
                if(x>y)
                {
                    c+=b*y;
                    x=x-y;
                    y=0;
                }
                else
                {
                    c+=b*x;
                    y=y-x;
                    x=0;
                }
            }
        }
        if(x>0)
        {
            c+=a*x;
        }
        if(y>0)
        {
            c+=a*y;
        }
        cout << c << '\n';
    }
}


#include <iostream>

using namespace std;

int main()
{
    unsigned long long n,a,b,x,y,c;
    cin >> n;
    for(unsigned long long i=0;i<n;i++)
    {
        cin >> x >> y >> a >> b;
        if(x>0 && y>0)
        {
            if(2*a<b)
            {
                while(x!=0 && y!=0)
                {
                    x--;
                    y--;
                    c+=a+a;
                }
            }
            else
            {
                while(x!=0 && y!=0)
                {
                    x--;
                    y--;
                    c+=b;
                }
            }
        }
        if(x>0)
        {
            while(x!=0)
            {
                x--;
                c+=a;
            }
        }
        if(y>0)
        {
            while(y!=0)
            {
                y--;
                c+=a;
            }
        }
        cout << c << endl;
    }
}


#include <iostream>

using namespace std;

int main()
{
    unsigned long long n,a,b,x,y,ac,bc,z;
    cin >> n;
    for(unsigned long long i=0;i<n;i++)
    {
        ac=0,bc=0;
        cin >> x >> y >> a >> b;
        if(2*a<b)
        {
            z=0;
        }
        else
        {
            z=1;
        }
        if(x>0 && y>0)
        {
            if(z==0)
            {
                while(x!=0 && y!=0)
                {
                    x--;
                    y--;
                    ac=ac+2;
                }
            }
            else
            {
                while(x!=0 && y!=0)
                {
                    x--;
                    y--;
                    bc=bc+1;
                }
            }
        }
        if(x>0)
        {
            while(x!=0)
            {
                x--;
                ac=ac+1;
            }
        }
        if(y>0)
        {
            while(y!=0)
            {
                y--;
                ac=ac+1;
            }
        }
        cout << ac*a+bc*b << endl;
    }
}


#include <iostream>

using namespace std;

int main()
{
    int n,a,b,x,y;
    long long c=0;
    cin >> n;
    for(int i=n;i--;)
    {
        c=0;
        cin >> x >> y >> a >> b;
        if(x>0 && y>0)
        {
            if(2*a<b)
            {
                if(x>y)
                {
                    c+=2*a*y;
                    x=x-y;
                    y=0;
                }
                else
                {
                    c+=2*a*x;
                    y=y-x;
                    x=0;
                }
            }
            else
            {
                if(x>y)
                {
                    c+=b*y;
                    x=x-y;
                    y=0;
                }
                else
                {
                    c+=b*x;
                    y=y-x;
                    x=0;
                }
            }
        }
        if(x>0)
        {
            c+=a*x;
        }
        if(y>0)
        {
            c+=a*y;
        }
        cout << c << '\n';
    }
}


#include <iostream>

using namespace std;

int main()
{
    int n,a,b,x,y;
    long long c=0;
    cin >> n;
    for(int i=n;i--;)
    {
        c=0;
        cin >> x >> y >> a >> b;
        if(x>0 && y>0)
        {
            if(2*a<b)
            {
                while(x!=0 && y!=0)
                {
                    x--;
                    y--;
                    c+=a+a;
                }
            }
            else
            {
                while(x!=0 && y!=0)
                {
                    x--;
                    y--;
                    c+=b;
                }
            }
        }
        if(x>0)
        {
            while(x!=0)
            {
                x--;
                c+=a;
            }
        }
        if(y>0)
        {
            while(y!=0)
            {
                y--;
                c+=a;
            }
        }
        cout << c << endl;
    }
}


#include <iostream>

using namespace std;

int main()
{
    long long n,a,b,c=0,x,y;
    cin >> n;
    for(long long i=n;i--;)
    {
        c=0;
        cin >> x >> y >> a >> b;
        if(x>0 && y>0)
        {
            if(2*a<b)
            {
                while(x!=0 && y!=0)
                {
                    x--;
                    y--;
                    c+=a+a;
                }
            }
            else
            {
                while(x!=0 && y!=0)
                {
                    x--;
                    y--;
                    c+=b;
                }
            }
        }
        if(x>0)
        {
            while(x!=0)
            {
                x--;
                c+=a;
            }
        }
        if(y>0)
        {
            while(y!=0)
            {
                y--;
                c+=a;
            }
        }
        cout << c << endl;
    }
}


#include <iostream>

using namespace std;

int main()
{
    long long n,a,b,x,y,ac,bc,z;
    cin >> n;
    for(long long i=0;i<n;i++)
    {
        ac=0,bc=0;
        cin >> x >> y >> a >> b;
        if(2*a<b)
        {
            z=0;
        }
        else
        {
            z=1;
        }
        while(x!=0 || y!=0)
        {
            if(x>0 && y>0)
            {
                if(z==0)
                {
                    while(x!=0 && y!=0)
                    {
                        x--;
                        y--;
                        ac=ac+2;
                    }
                }
                else
                {
                    while(x!=0 && y!=0)
                    {
                        x--;
                        y--;
                        bc=bc+1;
                    }
                }
            }
            else if(x>0)
            {
                while(x!=0)
                {
                    x--;
                    ac=ac+1;
                }
            }
            else if(y>0)
            {
                while(y!=0)
                {
                    y--;
                    ac=ac+1;
                }
            }
        }
        cout << ac*a+bc*b << endl;
    }
}


#include <iostream>

using namespace std;

int main()
{
    unsigned long long n,a,b,c=0,x,y;
    cin >> n;
    for(unsigned long long i=0;i<n;i++)
    {
        c=0;
        cin >> x >> y >> a >> b;
        if(x>0 && y>0)
        {
            if(2*a<b)
            {
                while(x!=0 && y!=0)
                {
                    x--;
                    y--;
                    c+=a+a;
                }
            }
            else
            {
                while(x!=0 && y!=0)
                {
                    x--;
                    y--;
                    c+=b;
                }
            }
        }
        if(x>0)
        {
            while(x!=0)
            {
                x--;
                c+=a;
            }
        }
        if(y>0)
        {
            while(y!=0)
            {
                y--;
                c+=a;
            }
        }
        cout << c << endl;
    }
}


#include <iostream>

using namespace std;

int main()
{
    unsigned long long n,a,b,c=0,x,y;
    cin >> n;
    for(unsigned long long i=0;i<n;i++)
    {
        cin >> x >> y >> a >> b;
        if(x>0 && y>0)
        {
            if(2*a<b)
            {
                while(x!=0 && y!=0)
                {
                    x--;
                    y--;
                    c+=a+a;
                }
            }
            else
            {
                while(x!=0 && y!=0)
                {
                    x--;
                    y--;
                    c+=b;
                }
            }
        }
        if(x>0)
        {
            while(x!=0)
            {
                x--;
                c+=a;
            }
        }
        if(y>0)
        {
            while(y!=0)
            {
                y--;
                c+=a;
            }
        }
        cout << c << endl;
    }
}


#include <iostream>

using namespace std;

int main()
{
    unsigned long long n,a,b,x,y,ac,bc,z;
    cin >> n;
    for(unsigned long long i=0;i<n;i++)
    {
        ac=0,bc=0;
        cin >> x >> y >> a >> b;
        if(x>0 && y>0)
        {
            if(2*a<b)
            {
                while(x!=0 && y!=0)
                {
                    x--;
                    y--;
                    ac+=2;
                }
            }
            else
            {
                while(x!=0 && y!=0)
                {
                    x--;
                    y--;
                    bc++;
                }
            }
        }
        if(x>0)
        {
            while(x!=0)
            {
                x--;
                ac++;
            }
        }
        if(y>0)
        {
            while(y!=0)
            {
                y--;
                ac++;
            }
        }
        cout << ac*a+bc*b << endl;
    }
}


#include <iostream>

using namespace std;

int main()
{
    unsigned long long n,a,b,x,y,ac,bc,z;
    cin >> n;
    for(unsigned long long i=0;i<n;i++)
    {
        ac=0,bc=0;
        cin >> x >> y >> a >> b;
        if(2*a<b)
        {
            z=0;
        }
        else
        {
            z=1;
        }
        while(x!=0 || y!=0)
        {
            if(x>0 && y>0)
            {
                if(z==0)
                {
                    while(x!=0 && y!=0)
                    {
                        x--;
                        y--;
                        ac=ac+2;
                    }
                }
                else
                {
                    while(x!=0 && y!=0)
                    {
                        x--;
                        y--;
                        bc=bc+1;
                    }
                }
            }
            else if(x>0)
            {
                while(x!=0)
                {
                    x--;
                    ac=ac+1;
                }
            }
            else if(y>0)
            {
                while(y!=0)
                {
                    y--;
                    ac=ac+1;
                }
            }
        }
        cout << ac*a+bc*b << endl;
    }
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
	int t;
	cin >> t;
	while(t--){

		ll x,y,a,b;
		cin >> x >> y >> a >> b;

		ll ans=0;

		if(x*y==0){
			ll n = x+y;
			ans = n*a;
		}else{

			ll min;
			ll diff;

			if(x<y){
				min = x;
				diff = (y-x);
			}
			else{
				min = y;
				diff = (x-y);
			}

			if(2*a >= b){
				ans = min*b;
			}
			else{
				a*=2;
				ans = min *a;
			}

			if(diff>0){
				ans += diff*a;
			}

		}
		cout<<ans<<endl;

	}
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	int t;
	cin >> t;
	while(t--){

		ll x,y,a,b;
		cin >> x >> y >> a >> b;

		ll ans=0;

		if(x*y<=0){
//			cout<<"dsd";
			int n = abs(x)+abs(y);
			ans = n*a;
//			cout<<ans;
		}else{
			x = abs(x);
			y = abs(y);

			int min;
			int diff;
			if(x<y){
				min = x;
				diff = (y-x);
			}
			else{
				min = y;
				diff = (x-y);
			}

			if(2*a >= b){
				ans = min*b;
			}
			else{
				ans = min * (2*a);
			}

			if(diff == 0){
				break;
			}
			else if(diff>0){
				ans += diff*a;
			}

		}
		cout<<ans<<endl;

	}
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	int t;
	cin >> t;
	while(t--){

		ll x,y,a,b;
		cin >> x >> y >> a >> b;

		ll ans;
		ll diff = abs(x-y);

		ll less;
		if(x<=y){
			less=x;
		}else{
			less = y;
		}

		ans = diff*a;
		ans += b*less;
		cout<<ans<<endl;
	}
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
	int t;
	cin >> t;
	while(t--){

		ll x,y,a,b;
		cin >> x >> y >> a >> b;

		ll ans=0;

		if(x*y==0){
			ll n = x+y;
			ans = n*a;
		}else{

			ll min;
			ll diff;

			if(x<y){
				min = x;
				diff = (y-x);
			}
			else{
				min = y;  //5
				diff = (x-y); // 4
			}
//			cout<<min<<" "<<diff<<endl; //5 4
			if(2*a >= b){
				ans = min*b;
			}
			else{
				int qa = 2*a;
				  // a =40
//				cout<<a<<endl; 40
				ans = min *qa; // 200
			}
//			cout<<ans<<endl;
			if(diff>0){
				ans = ans + (diff*a);
			}
		}
		cout<<ans<<endl;

	}
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	int t;
	cin >> t;
	while(t--){

		ll x,y,a,b;
		cin >> x >> y >> a >> b;

		ll ans=0;

		if(x*y<=0){
			ll n = abs(x)+abs(y);
			ans = n*a;
		}else{
			x = abs(x);
			y = abs(y);

			ll min;
			ll diff;

			if(x<y){
				min = x;
				diff = (y-x);
			}
			else{
				min = y;
				diff = (x-y);
			}

			if(2*a >= b){
				ans = min*b;
			}
			else{
				ans = min * (2*a);
			}

			if(diff == 0){
				break;
			}
			else if(diff>0){
				ans += diff*a;
			}

		}
		cout<<ans<<endl;

	}
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int t;
	cin >> t;
	while(t--){

		int x,y,a,b;
		cin >> x >> y >> a >> b;

		int closer;
		int far;
		if(abs(x-0) < abs(y-0)){
			closer = x;
			far = y;
		}else{
			closer = y;
			far = x;
		}
		int diff = abs(far-closer);
		int ans;
		ans = diff*a;
		ans += b*closer;
		cout<<ans<<endl;

	}
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
	int t;
	cin >> t;
	while(t--){

		ll x,y,a,b;
		cin >> x >> y >> a >> b;

		ll ans=0;

		if(x*y==0){
			ll n = x+y;
			ans = n*a;
		}else{

			ll min;
			ll diff;

			if(x<y){
				min = x;
				diff = (y-x);
			}
			else{
				min = y;  //5
				diff = (x-y); // 4
			}
//			cout<<min<<" "<<diff<<endl; //5 4
			if(2*a >= b){
				ans = min*b;
			}
			else{
				a*=2;  // a =40
//				cout<<a<<endl; 40
				ans = min *a; // 200
			}
//			cout<<ans<<endl;
			if(diff>0){
				ans = ans + (diff*(a/2));
			}
		}
		cout<<ans<<endl;

	}
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
	int t;
	cin >> t;
	while(t--){

		ll x,y,a,b;
		cin >> x >> y >> a >> b;

		ll ans=0;

		if(x*y==0){
			ll n = x+y;
			ans = n*a;
		}else{

			ll min;
			ll diff;

			if(x==y){
				ans = x*a;
			}

			if(x<y){
				min = x;
				diff = (y-x);
			}
			else{
				min = y;
				diff = (x-y);
			}

			if(2*a >= b){
				ans = min*b;
			}
			else{
				a*=2;
				ans = min *a;
			}

			if(diff == 0){
				break;
			}
			else if(diff>0){
				ans += diff*a;
			}

		}
		cout<<ans<<endl;

	}
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	int t;
	cin >> t;
	while(t--){

		ll x,y,a,b;
		cin >> x >> y >> a >> b;

		ll ans=0;

		if(x*y<=0){
//			cout<<"dsd";
			int n = abs(x)+abs(y);
			ans = n*a;
//			cout<<ans;
		}else{
			x = abs(x);
			y = abs(y);

			while( x > 0 && y > 0 ){

				if(2*a >= b ){
					x -= 1;
					y -= 1;

					ans += b;
				}
				else{

					x -= 1;
					y -= 1;

					ans += (2*a);

				}
			}

			if(x==0 && y==0){
				break;
			}
			else if( x > 0 ){
				ans += x*a;
			}
			else if( y>0 ){
				ans += y*a;
			}

		}
		cout<<ans<<endl;

	}
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
	int t;
	cin >> t;
	while(t--){

		ll x,y,a,b;
		cin >> x >> y >> a >> b;

		ll ans=0;

		if(x*y==0){
			ll n = x+y;
			ans = n*a;
		}else{

			ll min;
			ll diff;

			if(x<y){
				min = x;
				diff = (y-x);
			}
			else{
				min = y;
				diff = (x-y);
			}

			if(2*a >= b){
				ans = min*b;
			}
			else{
				a*=2;
				ans = min *a;
			}

			if(diff == 0){
				break;
			}
			else if(diff>0){
				ans += diff*a;
			}

		}
		cout<<ans<<endl;

	}
}


#include<iostream>
using namespace std;
int main(){
	int t;
	cin >> t;
	while(t--){

		int x,y,a,b;
		cin >> x >> y >> a >> b;

		int min, max;
		if(x>=y){
			max = x;
			min = y;
		}else{
			max = y;
			min = x;
		}

		int diff = max-min;
		int ans=0;

		ans = diff*a;

		ans += min*b;
		cout<<ans<<endl;

	}
}


#include <iostream>

using namespace std;

int main()
{
   long long int t,a,b,c,d,s1,s2,s3;
   cin>>t;
   while(t--)
   {
       cin>>a>>b;
       cin>>c>>d;
       if(a==0&&b==0)
       {
           cout<<0<<endl;
       }
       else if(a<b)
       {
           s1=a*d+(b-a)*c;
           cout<<s1<<endl;
       }
       else if(a>b)
       {
           s2=b*d+(a-b)*c;
           cout<<s2<<endl;
       }
       else if(a==b)
       {
           s3=a*d;
           cout<<s3<<endl;
       }
   }
   return 0;
}


#include <iostream>

using namespace std;

int main()
{
   int t;
   long long x,y,a,b,sum;
   cin>>t;
   while(t--)
   {
       cin>>x>>y>>a>>b;
       if((a*1.0)<(b/2.0))
       {
           sum=(x+y)*a;
       }
       else
       {
           if(x>y) sum=(x-y)*a+y*b;
           else if(x==y) sum=(x+y)*a;
           else sum=(y-x)*a+x*b;
       }
       cout<<sum<<endl;
   }

   return 0;
}


#include <iostream>

using namespace std;

int main()
{
   int t;
   long long x,y,a,b,s1,s2,s3,s4;
   cin>>t;
   while(t--)
   {
       cin>>x>>y;
       cin>>a>>b;
       if((a*1.0)>(b/2.0))
       {
           if(x==0&&y==0)
           {
               cout<<0<<endl;
           }
           else if(x<y)
           {
               s1=x*b+(y-x)*a;
               cout<<s1<<endl;
           }
           else if(x>y)
           {
               s2=y*b+(x-y)*a;
               cout<<s2<<endl;
           }
           else if(x==y)
           {
               s3=x*b;
               cout<<s3<<endl;
           }
        else
        {
            s4=(x+y)*a;
            cout<<s4<<endl;
        }
       }
   }
   return 0;
}


#include <iostream>

using namespace std;

int main()
{
   int t;
   long long x,y,a,b,sum;
   cin>>t;
   while(t--)
   {
       cin>>x>>y>>a>>b;
       if((a*1.0)<(b/2.0))
       {
           sum=(x+y)*a;
       }
       else
       {
           if(x>y) sum=(x-y)*a+y*b;
           else if(x==y) sum=x*a;
           else sum=(y-x)*a+x*b;
       }
       cout<<sum<<endl;
   }

   return 0;
}


#include <iostream>

using namespace std;

int main()
{
   int t,a,b,c,d,s1,s2,s3;
   cin>>t;
   while(t--)
   {
       cin>>a>>b;
       cin>>c>>d;
       if(a==0&&b==0)
       {
           cout<<0<<endl;
       }
       else if(a<b)
       {
           s1=a*d+(b-a)*c;
           cout<<s1<<endl;
       }
       else if(a>b)
       {
           s2=b*d+(a-b)*c;
           cout<<s2<<endl;
       }
       else if(a==b)
       {
           s3=a*d;
           cout<<s3<<endl;
       }
   }
   return 0;
}


#include <iostream>

using namespace std;

int main()
{
   long long t,x,y,a,b,s1,s2,s3,s4;
   cin>>t;
   while(t--)
   {
       cin>>x>>y;
       cin>>a>>b;
       if(a>(b/2))
       {
           if(x==0&&y==0)
           {
               cout<<0<<endl;
           }
           else if(x<y)
           {
               s1=x*b+(y-x)*a;
               cout<<s1<<endl;
           }
           else if(x>y)
           {
               s2=y*b+(x-y)*a;
               cout<<s2<<endl;
           }
           else if(x==y)
           {
               s3=x*b;
               cout<<s3<<endl;
           }
        else
        {
            s4=(x+y)*a;
            cout<<s4<<endl;
        }
       }
   }
   return 0;
}


#include <iostream>

using namespace std;

int main()
{
   int t,a,b,c,d,s1,s2,s3;
   cin>>t;
   while(t--)
   {
       cin>>a>>b;
       cin>>c>>d;
       if(a==0&&b==0)
       {
           cout<<"0"<<endl;
       }
       else if(a<b)
       {
           s1=a*d+(b-a)*c;
           cout<<s1<<endl;
       }
       else if(a>b)
       {
           s2=b*d+(a-b)*c;
           cout<<s2<<endl;
       }
       else if(a==b)
       {
           s3=a*d;
           cout<<s3<<endl;
       }
   }
   return 0;
}


#include <iostream>

using namespace std;

int main()
{
   int t,a,b,c,d,s1,s2,s3;
   cin>>t;
   while(t--)
   {
       cin>>a>>b;
       cin>>c>>d;
       if(a==0&&b==0)
       {
           cout<<"0"<<endl;
       }
       else if(a<b)
       {
           s1=a*d+(b-a)*c;
           cout<<s1<<endl;
       }
       else if(a>b)
       {
           s2=b*d+(a-b)*c;
           cout<<s2<<endl;
       }
       else if(a==b)
       {
           s3=a*d;
           cout<<s3<<endl;
       }
       return 0;
   }
}


#include <iostream>

using namespace std;

int main()
{
   int t;
   long long x,y,a,b,sum;
   cin>>t;
   while(t--)
   {
       cin>>x>>y>>a>>b;
       if((a*1.0)<(b/2.0))
       {
           sum=(x+y)*a;
       }
       else
       {
           if(x>y) sum=(x-y)*a+y*b;
           else if(x==y) sum=x*b;
           else sum=(y-x)*a+x*b;
       }
       cout<<sum<<endl;
   }

   return 0;
}


#include <iostream>

using namespace std;

int main()
{
   int t;
   long int a,b,c,d,s1,s2,s3;
   cin>>t;
   while(t--)
   {
       cin>>a>>b;
       cin>>c>>d;
       if(a==0&&b==0)
       {
           cout<<0<<endl;
       }
       else if(a<b)
       {
           s1=a*d+(b-a)*c;
           cout<<s1<<endl;
       }
       else if(a>b)
       {
           s2=b*d+(a-b)*c;
           cout<<s2<<endl;
       }
       else if(a==b)
       {
           s3=a*d;
           cout<<s3<<endl;
       }
   }
   return 0;
}


#include <iostream>

using namespace std;

int main()
{
   int t;
   long long int a,b,c,d,s1,s2,s3;
   cin>>t;
   while(t--)
   {
       cin>>a>>b;
       cin>>c>>d;
       if(a==0&&b==0)
       {
           cout<<0<<endl;
       }
       else if(a<b)
       {
           s1=a*d+(b-a)*c;
           cout<<s1<<endl;
       }
       else if(a>b)
       {
           s2=b*d+(a-b)*c;
           cout<<s2<<endl;
       }
       else if(a==b)
       {
           s3=a*d;
           cout<<s3<<endl;
       }
   }
   return 0;
}


// Problem : A. Road To Zero
// Contest : Codeforces - Educational Codeforces Round 86 (Rated for Div. 2)
// URL : https://codeforces.com/contest/1342/problem/A
// Memory Limit : 256 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

int main(){
	int t;
	cin >> t;
	while(t--){
		int x,y,a,b;
		cin >> x >> y;
		cin >> a >> b;
		int minn = min(x,y), maxn = max(x,y);
		cerr << minn << " " << maxn << "\n";
		cout << (maxn-minn) * a + minn * b << "\n";
	}
	return 1;
}


// Problem : A. Road To Zero
// Contest : Codeforces - Educational Codeforces Round 86 (Rated for Div. 2)
// URL : https://codeforces.com/contest/1342/problem/A
// Memory Limit : 256 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

int main(){
	int t;
	cin >> t;
	while(t--){
		int x,y,a,b;
		cin >> x >> y;
		cin >> a >> b;
		int minn = min(x,y), maxn = max(x,y);
		// cerr << minn << " " << maxn << "\n";
		cout << (maxn-minn) * a + minn * b << "\n";
	}
	return 1;
}


// Problem : A. Road To Zero
// Contest : Codeforces - Educational Codeforces Round 86 (Rated for Div. 2)
// URL : https://codeforces.com/contest/1342/problem/A
// Memory Limit : 256 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

int main(){
	cout << "1\n";
	return 1;
}


// Problem : A. Road To Zero
// Contest : Codeforces - Educational Codeforces Round 86 (Rated for Div. 2)
// URL : https://codeforces.com/contest/1342/problem/A
// Memory Limit : 256 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

int main(){
	int t;
	cin >> t;
	while(t--){
		long long int x,y,a,b;
		cin >> x >> y;
		cin >> a >> b;
		int minn = min(x,y), maxn = max(x,y);
		// cerr << minn << " " << maxn << "\n";
		long long temp = (maxn-minn) * a + minn * b;
		long long res = a * (x+y);
		res = min(temp,res);
		cout << res << "\n";
	}
	return 0;
}


// Problem : A. Road To Zero
// Contest : Codeforces - Educational Codeforces Round 86 (Rated for Div. 2)
// URL : https://codeforces.com/contest/1342/problem/A
// Memory Limit : 256 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

int main(){
	int t;
	cin >> t;
	while(t--){
		long long int x,y,a,b;
		cin >> x >> y;
		cin >> a >> b;
		int minn = min(x,y), maxn = max(x,y);
		// cerr << minn << " " << maxn << "\n";
		long long temp = (maxn-minn) * a + minn * b;
		cout << temp << "\n";
	}
	return 0;
}


// Problem : A. Road To Zero
// Contest : Codeforces - Educational Codeforces Round 86 (Rated for Div. 2)
// URL : https://codeforces.com/contest/1342/problem/A
// Memory Limit : 256 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

int32_t main(){
	int t;
	cin >> t;
	while(t--){
		 int x,y,a,b;
		cin >> x >> y;
		cin >> a >> b;
		int minn = min(x,y), maxn = max(x,y);
		// cerr << minn << " " << maxn << "\n";
		int temp = (maxn-minn) * a + minn * b;
		int res = a * (x+y);
		res = min(temp,res);
		cout << res << "\n";
	}
	return 0;
}


// Problem : A. Road To Zero
// Contest : Codeforces - Educational Codeforces Round 86 (Rated for Div. 2)
// URL : https://codeforces.com/contest/1342/problem/A
// Memory Limit : 256 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

int main(){
	int t;
	cin >> t;
	while(t--){
		int x,y,a,b;
		cin >> x >> y;
		cin >> a >> b;
		int minn = min(x,y), maxn = max(x,y);
		// cerr << minn << " " << maxn << "\n";
		cout << (maxn-minn) * a + minn * b << "\n";
	}
	return 0;
}


#include<iostream>
using namespace std;
int main()
{
    long long int t,x, y, a, b, total=0, cnt = 0;
    cin>>t;
    while(t--)
    {
        cin>>x>>y>>a>>b;
        if(x==0 && y==0)
        {
            cnt = 1;
        }
        if(x>y)
            {
                total = total + (x-y)*a ;
            }
        else
            {
                total = total+(y-x)*a;
            }
        ///Both are equal.

        if(2*a < b)
        {
            total= total + (2*a)*x;
        }
        else
        {
            total = total + b*x;
        }
        ///output:-

    if(cnt==1)
    {
        cout<<"0"<<endl;
    }
    else
    {
        cout<<total<<endl;
    }

    }

}


#include<iostream>
using namespace std;
int main()
{
    int t,x, y, a, b, total=0, cnt = 0;
    cin>>t;
    while(t--)
    {
        cin>>x>>y>>a>>b;
        if(x == y)
        {
            cnt = 1;
        }
        if(x>y)
            {
                total = total + (x-y)*a ;
            }
        else
            {
                total = total+(y-x)*a;
            }
        ///Both are equal.

        if(2*a < b)
        {
            total= total + (2*a)*x;
        }
        else
        {
            total = total + b*x;
        }
        ///output:-

    if(cnt==1)
    {
        cout<<"0"<<endl;
    }
    else
    {
        cout<<total<<endl;
    }

    }

}


#include<iostream>
using namespace std;
int main()
{
    int t,x, y, a, b, total=0, cnt = 0;
    cin>>t;
    while(t--)
    {
        cin>>x>>y>>a>>b;
        if(x == y)
        {
            cnt = 1;
        }
        if(x>y)
            {
                total = total + (x-y)*a ;
            }
        else
            {
                total = total+(y-x)*a;
            }
        ///Both are equal.

        if(2*a < b)
        {
            total= total + (2*a)*x;
        }
        else
        {
            total = total + b*x;
        }

    }
    if(cnt==1)
    {
        cout<<"0";
    }
    else
    {
        cout<<total;
    }

///ASM
}


#include<iostream>
using namespace std;
int main()
{
    int t,x, y, a, b, total=0, cnt = 0;
    cin>>t;
    while(t--)
    {
        cin>>x>>y>>a>>b;
        if(x==0 && y==0)
        {
            cnt = 1;
        }
        if(x>y)
            {
                total = total + (x-y)*a ;
            }
        else
            {
                total = total+(y-x)*a;
            }
        ///Both are equal.

        if(2*a < b)
        {
            total= total + (2*a)*x;
        }
        else
        {
            total = total + b*x;
        }
        ///output:-

    if(cnt==1)
    {
        cout<<"0"<<endl;
    }
    else
    {
        cout<<total<<endl;
    }

///ASM
    }

}


#include<stdio.h>
#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
    int n,t,i,cnt1,cnt2;
    long long x,y,a,b,s;
    cin>>t;
    for(i=0;i<t;i++){
    cin>>x>>y;
    cin>>a>>b;
    if(x>y) swap(x,y);
    cnt1=0,cnt2=0;
    while(y>x){
      cnt1++;
      y--;
    }
    while(x>0){
      cnt2++;
      x--;
    }
    s=(cnt1*a)+(cnt2*b);
    cout<<s<<endl;
    }
return 0;
}


#include<stdio.h>
#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
    int n,t,i,cnt1,cnt2;
    long long x,y,a,b,s;
    cin>>t;
    for(i=0;i<t;i++){
    cin>>x>>y;
    cin>>a>>b;
    //if(x>y) swap(x,y);
    if(x>0&&y>0)
    s=(abs(y-x)*a)+(min(x,y)*b);
    if(x>0&&y<=0)
    s=x*b;
    if(x<=0&&y>0)
    s=y*b;
    cout<<s<<endl;
    s=0;
    }
return 0;
}


#include<stdio.h>
#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
    int n,t,i,cnt1,cnt2;
    long long x,y,a,b,s;
    cin>>t;
    for(i=0;i<t;i++){
    cin>>x>>y;
    cin>>a>>b;
    //if(x>y) swap(x,y);
    if(x>0&&y>0)
    s=(abs(y-x)*a)+(min(x,y)*b);
    if(x>0&&y<=0)
    s=x*a;
    if(x<=0&&y>0)
    s=y*a;
    cout<<s<<endl;
    s=0;
    }
return 0;
}


#include<stdio.h>
#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
    int n,t,i,cnt1,cnt2;
    long long x,y,a,b,s;
    cin>>t;
    for(i=0;i<t;i++){
    cin>>x>>y;
    cin>>a>>b;
    //if(x>y) swap(x,y);
    cnt1=abs(y-x);
    cnt2=min(x,y);
    s=(cnt1*a)+(cnt2*b);
    cout<<s<<endl;
    }
return 0;
}


#include<stdio.h>
#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
    int n,t,i,cnt1,cnt2;
    long long x,y,a,b,s;
    cin>>t;
    for(i=0;i<t;i++){
    cin>>x>>y;
    cin>>a>>b;
    //if(x>y) swap(x,y);
    if(x>0&&y>0)
    s=(abs(y-x)*a)+(min(x,y)*b);
    if(x>0&&y<=0)
    s=x*b;
    if(x<=0&&y>0)
    s=y*b;
    cout<<s<<endl;
    }
return 0;
}