import java.io.BufferedReader;
import java.io.CharConversionException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamCorruptedException;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Iterator;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;
public class Main {
// static int[] ch= {7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2};
// static char[] ch= {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
public static void main(String[] args) {
// TODO Auto-generated method stub
PrintWriter out=new PrintWriter(System.out);
InputReader in=new InputReader(System.in);
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int[][] ch=new int[2][n];
for(int i=0;i<n;i++) {
ch[0][i]=sc.nextInt();
}
for(int i=0;i<n;i++) {
ch[1][i]=sc.nextInt();
}
int[] res=new int[n];
for(int i=0;i<n;i++) {
if(ch[0][i]==0&&ch[1][i]==0) res[i]=0;
if(ch[0][i]==0&&ch[1][i]==1) res[i]=1;
if(ch[0][i]==1&&ch[1][i]==0) res[i]=2;
if(ch[0][i]==1&&ch[1][i]==1) res[i]=3;
}
int ans=0,id=-1;
for(int i=0;i<n;i++) {
if(res[i]==0) continue;
if(id!=-1) {
if(res[i]==3||res[id]==3||res[i]==res[id]) {
ans+=(i-id-1);
}else {
res[i]=3;
ans+=(i-id);
}
}
id=i;
}
System.out.println(ans);
}
}
class InputReader{
private final InputStream stream;
private final byte[] buf=new byte[8192];
private int curChar,snumChars;
public InputReader(InputStream st) {
this.stream=st;
}
public int read() {
if(snumChars==-1)
throw new InputMismatchException();
if(curChar>=snumChars) {
curChar=0;
try {
snumChars=stream.read(buf);
}catch (IOException e) {
// TODO: handle exception
throw new InputMismatchException();
}
if(snumChars<=0)
return -1;
}
return buf[curChar++];
}
public int nextInt() {
int c=read();
while(isSpaceChar(c)) {
c=read();
}
int sgn=1;
if(c=='-') {
sgn=-1;
c=read();
}
int res=0;
do {
res*=10;
res+=c-'0';
c=read();
}while(!isSpaceChar(c));
return res*sgn;
}
public long nextLong() {
int c=read();
while(isSpaceChar(c)) {
c=read();
}
int sgn=1;
if(c=='-') {
sgn=-1;
c=read();
}
int res=0;
do {
res*=10;
res+=c-'0';
c=read();
}while(!isSpaceChar(c));
return res*sgn;
}
public int[] nextIntArray(int n) {
int a[]=new int[n];
for(int i=0;i<n;i++) {
a[i]=nextInt();
}
return a;
}
public String readString() {
int c=read();
while(isSpaceChar(c)) {
c=read();
}
StringBuilder res=new StringBuilder();
do {
res.appendCodePoint(c);
c=read();
}while(!isSpaceChar(c));
return res.toString();
}
public String nextLine() {
int c=read();
while(isSpaceChar(c)) {
c=read();
}
StringBuilder res=new StringBuilder();
do {
res.appendCodePoint(c);
c=read();
}while(!isEndOfLine(c));
return res.toString();
}
private boolean isEndOfLine(int c) {
// TODO Auto-generated method stub
return c=='\n'||c=='\r'||c==-1;
}
private boolean isSpaceChar(int c) {
// TODO Auto-generated method stub
return c==' '||c=='\n'||c=='\r'||c=='\t'||c==-1;
}
}