Pavel cooks barbecue. There are n skewers, they lay on a brazier in a row, each on one of n positions. Pavel wants each skewer to be cooked some time in every of n positions in two directions: in the one it was directed originally and in the reversed direction.

Pavel has a plan: a permutation p and a sequence b1, b2, ..., bn, consisting of zeros and ones. Each second Pavel move skewer on position i to position pi, and if bi equals 1 then he reverses it. So he hope that every skewer will visit every position in both directions.

Unfortunately, not every pair of permutation p and sequence b suits Pavel. What is the minimum total number of elements in the given permutation p and the given sequence b he needs to change so that every skewer will visit each of 2n placements? Note that after changing the permutation should remain a permutation as well.

There is no problem for Pavel, if some skewer visits some of the placements several times before he ends to cook. In other words, a permutation p and a sequence b suit him if there is an integer k (k ≥ 2n), so that after k seconds each skewer visits each of the 2n placements.

It can be shown that some suitable pair of permutation p and sequence b exists for any n.

Input

The first line contain the integer n (1 ≤ n ≤ 2·105) — the number of skewers.

The second line contains a sequence of integers p1, p2, ..., pn (1 ≤ pi ≤ n) — the permutation, according to which Pavel wants to move the skewers.

The third line contains a sequence b1, b2, ..., bn consisting of zeros and ones, according to which Pavel wants to reverse the skewers.

Output

Print single integer — the minimum total number of elements in the given permutation p and the given sequence b he needs to change so that every skewer will visit each of 2n placements.

Examples

Input

4
4 3 2 1
0 1 1 1


Output

2


Input

3
2 3 1
0 0 0


Output

1

Note

In the first example Pavel can change the permutation to 4, 3, 1, 2.

In the second example Pavel can change any element of b to 1.
     import java.util.*; 
            import java.math.*;
            import java.io.*;
            import java.text.DecimalFormat;
            import java.math.BigInteger;
            public class Main{
                //static int d=20;
                static long mod=1000000007 ;
                static HashMap<String,Double> hm=new HashMap<>(); 
                static ArrayList<ArrayList<Integer>> arr;
                static long[] dp1,dp2;
                static int[] a;
                static int[] vis,num;
                static long max;
                static int id;
                public static void main(String[] args)  throws IOException {
                    boolean online =false;
                    String fileName = "C-large-practice";
                    PrintWriter out; 
                    if (online) {
                        s.init(new FileInputStream(new File(fileName + ".in")));
                         out= new PrintWriter(new FileWriter(fileName + "out.txt"));
                    }
                     else {
                        s.init(System.in);   
                    
                        out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
                    }//r,b,y,g
                    int n=s.ni();
                    int[] a=new int[n];
                    int[] b=new int[n];
                    for(int i=0;i<n;i++)
                        a[i]=s.ni()-1;
                    
                    int add=0;
                    for(int i=0;i<n;i++){
                        b[i]=s.ni();
                        
                        if(b[i]==1)
                            add++;
                    }
                    int[] vis=new int[n];
                    int cycle=0;
                    int single=0;
                   // ArrayList<Integer> arr=new ArrayList<Integer>();
                    for(int i=0;i<n;i++){
                        if(vis[i]==0){
                            cycle++;
                            int j=i;
                            int ct=0;
                            while(vis[j]==0){
                                ct++;
                                vis[j]++;
                                j=a[j];
                            }

                            
                        }
                    }
                    int ans=0;

                   
                    ans=cycle;
               
                    if(cycle==1)
                        ans=0;
                    
                    if(add%2==0)
                        ans++;
                    out.println(ans);

                    out.close();
     
                }
                
                public static long gcd(long a, long b){
                        if (a == 0) return b;
                        return gcd(b % a, a);
                }
                    
                public static boolean check(long x){
                    if(x%4==0 || x%7==0 || x%11==0)
                        return true;
                    if(x<4 || x<7 || x<11)
                        return false;
                    if(x%2==0){
                        return check(x/2);
                    }
                    else
                        return check(x/2) && check((x+1)/2);
                }
                public static int angle(int x1,int x2,int x3,int y1,int y2,int y3){
                    long val=(y2-y1)*1L*(x3-x2)-(y3-y2)*1L*(x2-x1);
                    if(val<0)
                        return 1;
                    else if(val>0)
                        return -1;
                    else
                        return 0;
                }
                
                static class BIT{
                
                    int N;
                    int tree[];
                    
                    BIT(int N){
                        this.N = N;
                        tree = new int[N + 1];
                    }
                    
                    void update(int idx){
                        while(idx <= N){
                            tree[idx]++;
                            idx += (idx & -idx);
                        }
                    }
                    
                    int query(int l,int r){
                        if(l == 1)
                            return read(r);
                        else
                            return read(r) - read(l-1);
                    }
                    
                    int read(int idx){
                        int sum = 0;
                        while(idx > 0){
                            sum += tree[idx];
                            idx -= (idx & -idx);
                        }
                        return sum;
                    }
                }
                public static boolean pal(String a){
                    int i=0;
                    int j=a.length()-1;
                    while(i<j){
                        if(a.charAt(i)!=a.charAt(j)){
                            return false;
                        }
                        i++;
                        j--;
                    }
                    return true;
                        
                }
                public static long find(long n,long k){
                    if(n==2){
                        if(k==1 || k==3)
                            return 1;
                        else
                            return 2;
                    }
                    long t=pow2(2,n,mod)-1;
                    long z=(t+1)/2;
                    if(k==z)
                        return n;
                    if(k<z)
                        return find(n-1,k);
                    else
                        return find(n-1,k-z);
                }
                public static long pow2(long a,long b,long mod){
                        long ans=1;
                        while(b>0){
                            if(b%2==1)
                                ans=(a*ans)%mod;
                            a=(a*a)%mod;
                            b/=2;
                        }
                        return  ans;
                }
                public static long pow3(long a,long b){
                        long ans=1;
                        while(b>0){
                            if(b%2==1)
                                ans=(a*ans);
                            a=(a*a);
                            b/=2;
                        }
                        return  ans;
                }
     
                 static class name implements Comparable<name> {
                    long l,b,h;
                    public name(long   x,long y,long z){
                        {
                            l=x;
                            b=y;
                        }
                        
                        
                        h=z;
                    }
                    public int compareTo(name o){
                        return -(int)(l*b-o.l*o.b);
                    }
                    
                }
                public static class s {
                    static BufferedReader reader;
                    static StringTokenizer tokenizer;
                
                    /** call this method to initialize reader for InputStream */
                    static void init(InputStream input) {
                        reader = new BufferedReader(
                                    new InputStreamReader(input) );
                        tokenizer = new StringTokenizer("");
                    }   
                
                    /** get next word */
                    static String ns() throws IOException {
                        while ( ! tokenizer.hasMoreTokens() ) {
                            //TODO add check for eof if necessary
                            tokenizer = new StringTokenizer(
                                reader.readLine() );
                        }
                        return tokenizer.nextToken();
                    }
                
                    static int ni() throws IOException {
                        return Integer.parseInt( ns() );
                    }
                
                    static double nd() throws IOException {
                        return Double.parseDouble( ns() );
                    }
                    static long nl() throws IOException {
                        return Long.parseLong( ns() );
                    }
                }
            }
                    
