#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	int dp[2][103];
	int n;
	int bill[2][103];
	while(cin >> n , n){
		rep(i,2)rep(j,103)dp[i][j] = (1<<21);
		rep(i,2)rep(j,103)bill[i][j] = 0;
		rep(i,2)rep(j,n)cin >> bill[i][j];
		
		dp[0][0] = dp[1][0] = 0;
		
		rep(loop,n+1000){
			rep(i,n){
				rep(bit,2){
					if(bill[bit][i] == 1){
						if(bill[bit][i+1] == 1){
							dp[bit][i+1] = min(dp[bit][i+1],dp[bit][i]);
						}else{
							dp[bit^1][i] = min(dp[bit^1][i],dp[bit][i]+1);
							dp[bit^1][i+1] = min(dp[bit^1][i+1],dp[bit][i]+1);
							dp[bit^1][i+2] = min(dp[bit^1][i+2],dp[bit][i]+1);
						}
					}else if(bill[bit][i] == 2){
						dp[bit][i-1] = min(dp[bit][i-1],dp[bit][i]);
					}else if(bill[bit][i] == 0){
						dp[bit^1][i] = min(dp[bit^1][i],dp[bit][i]+1);
						dp[bit^1][i+1] = min(dp[bit^1][i+1],dp[bit][i]+1);
						dp[bit^1][i+2] = min(dp[bit^1][i+2],dp[bit][i]+1);
					}
				}
			}
		}
		rep(bit,2){
			if(bill[bit][n-1] != 2)dp[bit][n] = min(dp[bit][n-1],dp[bit][n]);
		}
		int ret = min(dp[0][n],dp[1][n]);
		if(ret != (1<<21) ){
			cout << ret << endl;
		}else{
				cout << "NA" << endl;
		}
	}
}