Problem: PolandBall lives in a forest with his family. There are some trees in the forest. Trees are undirected acyclic graphs with k vertices and k - 1 edges, where k is some integer. Note that one vertex is a valid tree.

There is exactly one relative living in each vertex of each tree, they have unique ids from 1 to n. For each Ball i we know the id of its most distant relative living on the same tree. If there are several such vertices, we only know the value of the one with smallest id among those.

How many trees are there in the forest?

Input

The first line contains single integer n (1 ≤ n ≤ 104) — the number of Balls living in the forest.

The second line contains a sequence p1, p2, ..., pn of length n, where (1 ≤ pi ≤ n) holds and pi denotes the most distant from Ball i relative living on the same tree. If there are several most distant relatives living on the same tree, pi is the id of one with the smallest id.

It's guaranteed that the sequence p corresponds to some valid forest.

Hacking: To hack someone, you should provide a correct forest as a test. The sequence p will be calculated according to the forest and given to the solution you try to hack as input. Use the following format:

In the first line, output the integer n (1 ≤ n ≤ 104) — the number of Balls and the integer m (0 ≤ m < n) — the total number of edges in the forest. Then m lines should follow. The i-th of them should contain two integers ai and bi and represent an edge between vertices in which relatives ai and bi live. For example, the first sample is written as follows:
    
    
      
    5 3  
    1 2  
    3 4  
    4 5  
    

Output

You should output the number of trees in the forest where PolandBall lives.

Interaction

From the technical side, this problem is interactive. However, it should not affect you (except hacking) since there is no interaction.

Examples

Input

5
2 1 5 3 3

Output

2

Input

1
1


Output

1

Note

In the first sample testcase, possible forest is: 1-2 3-4-5. 

There are 2 trees overall.

In the second sample testcase, the only possible graph is one vertex and no edges. Therefore, there is only one tree.

Solution (in JAVA):

Solution:
//package credit;


import java.awt.*;
import java.beans.IntrospectionException;
import java.io.PrintWriter;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.sql.SQLIntegrityConstraintViolationException;
import java.util.*;
import java.util.List;

public class sas {
    static boolean v[];
    static int ans[];
    int size[];
    static int count=0;
    static int dsu=0;
    static int c=0;
    int min=Integer.MAX_VALUE;
    int max=Integer.MIN_VALUE;
    boolean aBoolean=true;
    PrintWriter printWriter = new PrintWriter(System.out);
    static class Reader
        {
            final private int BUFFER_SIZE = 1 << 16;
            private DataInputStream din;
            private byte[] buffer;
            private int bufferPointer, bytesRead;

            public Reader()
            {
                din = new DataInputStream(System.in);
                buffer = new byte[BUFFER_SIZE];
                bufferPointer = bytesRead = 0;
            }

            public Reader(String file_name) throws IOException
            {
                din = new DataInputStream(new FileInputStream(file_name));
                buffer = new byte[BUFFER_SIZE];
                bufferPointer = bytesRead = 0;
            }

            public String readLine() throws IOException
            {
                byte[] buf = new byte[64]; // line length
                int cnt = 0, c;
                while ((c = read()) != -1)
                {
                    if (c == '\n')
                        break;
                    buf[cnt++] = (byte) c;
                }
                return new String(buf, 0, cnt);
            }

            public int nextInt() throws IOException
            {
                int ret = 0;
                byte c = read();
                while (c <= ' ')
                    c = read();
                boolean neg = (c == '-');
                if (neg)
                    c = read();
                do
                {
                    ret = ret * 10 + c - '0';
                }  while ((c = read()) >= '0' && c <= '9');

                if (neg)
                    return -ret;
                return ret;
            }

            public long nextLong() throws IOException
            {
                long ret = 0;
                byte c = read();
                while (c <= ' ')
                    c = read();
                boolean neg = (c == '-');
                if (neg)
                    c = read();
                do {
                    ret = ret * 10 + c - '0';
                }
                while ((c = read()) >= '0' && c <= '9');
                if (neg)
                    return -ret;
                return ret;
            }

            public double nextDouble() throws IOException
            {
                double ret = 0, div = 1;
                byte c = read();
                while (c <= ' ')
                    c = read();
                boolean neg = (c == '-');
                if (neg)
                    c = read();

                do {
                    ret = ret * 10 + c - '0';
                }
                while ((c = read()) >= '0' && c <= '9');

                if (c == '.')
                {
                    while ((c = read()) >= '0' && c <= '9')
                    {
                        ret += (c - '0') / (div *= 10);
                    }
                }

                if (neg)
                    return -ret;
                return ret;
            }

            private void fillBuffer() throws IOException
            {
                bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
                if (bytesRead == -1)
                    buffer[0] = -1;
            }

            private byte read() throws IOException
            {
                if (bufferPointer == bytesRead)
                    fillBuffer();
                return buffer[bufferPointer++];
            }

            public void close() throws IOException
            {
                if (din == null)
                    return;
                din.close();
            }
        }
        int parent[];
        int rank[];
        public static void main(String[] args) throws IOException {
            sas g = new sas();
            g.go();
        }
        public void go() throws IOException {
            Reader scanner = new Reader();
            int t = 1;
            for (int i = 0; i < t; i++) {
                int n=scanner.nextInt();
                parent=new int[n];
                size=new int[n];
                rank=new int[n];
                parent(n);
                Set<Integer> set=new HashSet<>();
                for (int j = 0; j <n ; j++) {
                    int k=scanner.nextInt()-1;
                    union(j,k);
                }
                for (int j = 0; j < n; j++) {
                    set.add(find(j));
                }
                printWriter.print(set.size());
                printWriter.flush();
            }
        }
        public void parent(int n){
            for (int i = 0; i < n; i++) {
                parent[i]=i;
                rank[i]=1;
                size[i]=1;
            }
        }
        public void union(int i,int j){
            int root1=find(i);
            int root2=find(j);
            if(root1==root2){
                return;
            }
            if(rank[root1]>rank[root2]){
                parent[root2]=root1;
                size[root1]+=size[root2];
            }
            else if(rank[root1]<rank[root2]){
                parent[root1]=root2;
                size[root2]+=size[root1];
            }
            else{
                parent[root2]=root1;
                rank[root1]+=1;
                size[root1]+=size[root2];
            }
        }
        public int find(int p){
           if(parent[p]!=p){
               parent[p]=find(parent[p]);
           }
           return parent[p];
//            if(parent[p]==-1){
//                return -1;
//            }
//            else if(parent[p]==p){
//                return p;
//            }
//            else {
//                parent[p]=find(parent[p]);
//                return parent[p];
//            }
        }
        public void make(int p){
            parent[p]=p;
            rank[p]=1;
            v[p]=true;
        }
        Random rand = new Random();
        public void sort(int[] a, int n) {
                for (int i = 0; i < n; i++) {
                   int j = rand.nextInt(i + 1);
                   int tmp = a[i];
                   a[i] = a[j];
                   a[j] = tmp;
                }
                Arrays.sort(a, 0, n);
        }
        public long gcd(long a,long b){
               if(b==0){
                  return a;
               }
               return gcd(b,a%b);
        }
        private void dfs2(ArrayList<Integer>[]arrayList,int j,int count){
            ans[j]=count;
            for(int i:arrayList[j]){
                if(ans[i]==-1){
                    dfs2(arrayList,i,count);
                }
            }
        }
        private void dfs(ArrayList<Integer>[] arrayList, int j) {
            v[j]=true;
            count++;
            for(int i:arrayList[j]){
                if(v[i]==false) {
                    dfs(arrayList, i);
                }
            }
        }
}

    class Pair{
    long x;
    long y;
    public Pair(long x,long y){
        this.x=x;
        this.y=y;
    }
}
class Sorting implements Comparator<Pair> {
    public int compare(Pair p1,Pair p2){
        return Long.compare(p1.x,p2.x);
    }

}