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.
import java.io.*;
import java.util.*;

public class Solution {

//	public static final double EPS = 1e-9;
//	public static final int MOD = 1000000009;
//	public static final double PI = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679;
//	public static final int DX[] = {1, -1, 0, 0};
//	public static final int DY[] = {0, 0, 1, -1};
//	public static final int sievesize = (int) (1e6);
//	public static boolean[] prime;

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		
		int[] par, rank;
		
		public int find(int x) {
			if (par[x] != x) return par[x] = find(par[x]);
			return par[x];
		}
		
		public void union(int x, int y) {
			x = find(x);
			y = find(y);
			if (x != y) {
				if (rank[x] < rank[y]) par[x] = y;
				else par[y] = x;
				if (rank[x] == rank[y]) rank[x]++;
 			}
		}

		public void solve(int testNumber, InputReader in, OutputWriter out) throws IOException {
			int n = in.nextInt();
			int[] dis = in.nextIntArray(n);
			par = new int[n + 1];
			rank = new int[n + 1];
			for (int i = 0; i <= n; i++) par[i] = i;
			for (int i = 0; i < n; i++) union(i + 1, dis[i]);
			Set<Integer> set = new HashSet<>();
			for (int i = 1; i <= n; i++) set.add(find(i));
			out.println(set.size(), "\n");
		}

//		static class Node {
//			String name;
//			LinkedList<Node> list;
//			
//			public Node(String name) {
//				this.name = name;
//				list = new LinkedList<>();
//			}
//		}
        
		static class Pair<T1, T2> {   	
	      	T1 first;
	      	T2 second;
		        	
		    public Pair(T1 first, T2 second) {
	    		this.first = first;
				this.second = second;
			}
	    }
		
//		public void sieve() {
//			prime = new boolean[sievesize + 1];
//			Arrays.fill(prime, true);
//		    for(int x = 2; x * x < sievesize; x++) { 
//		    	if(prime[x])
//		    		for(int y = x * 2; y < sievesize; y += x) 
//		    			prime[y] = false; 
//		    }
//		} 

//		public int[] shuffle(int arr[], Random gen) {
//			for (int i = arr.length - 1; i > 0; i--) {
//	            int index = gen.nextInt(i + 1);
//	            int temp = arr[index];
//	            arr[index] = arr[i];
//	            arr[i] = temp;
//			}
//			return arr;
//		}
	
//		public boolean triangle(long a, long b, long c) {
//		    return ((a+b) > c && (b+c) >a && (a+c) > b);
//		}
	
//		public boolean isPerfectSquare(long n) {
//			if (n < 0) return false;
//		    long test = (long) (Math.sqrt(n) + 0.5);
//		    return test*test == n;
//		}
	
//		public int isnum(char s) {
//			if(s=='1' || s=='2' || s=='3' || s=='4' || s=='5' || s=='6' || s=='7' || s=='8' || s=='9' || s=='0')  return 1; 
//			return 0;
//		}
	
//		public long nextPowerOf2(long n) {
//		    n--;
//		    n |= n >> 1;
//		    n |= n >> 2;
//		    n |= n >> 4;
//		    n |= n >> 8;
//		    n |= n >> 16;
//		    n++;
//		    return n;
//		}
	
//		public int gcd(int a, int b) {
//		    int t; 
//		    while (b > 0){ 
//		    	a = a % b; 
//		    	t = a; 
//		    	a = b; 
//		    	b = t; 
//		    }
//		    return a;
//		}
		
//		public int lcm(int x, int y) {
//			int a = Math.max(x, y);
//			while (true) {
//				if (a % x == 0 && a % y == 0) return a;
//				a++;
//			}
//		}
	
//		public static int findGcdArray(int[] arr) {
//			int min = Integer.MAX_VALUE;
//			for (int i = 0; i < arr.length; i++)
//				min = Math.min(min, arr[i]);
//			while (min > 1) {
//				int i = 0, s = 0;
//				while (i < arr.length) {
//					s += arr[i] % min;
//					i++;
//				}
//				if (s == 0) return min;
//				min--;
//			}
//			return 1;
//		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}
		
		private void tokenize() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}

		public String next() {
			tokenize();
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}
		
		public char nextChar() {
			return next().charAt(0);
		}
		
		public float nextFloat() {
			return Float.parseFloat(next());
		}
		
		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int size) {
			tokenize();
			int[] arr=new int[size];
			for(int i = 0; i < size; i++) {
				tokenize();
				arr[i] = Integer.parseInt(tokenizer.nextToken());
			}
			return arr;
		}
		
		public long[] nextLongArray(int size) {
			tokenize();
			long[] arr=new long[size];
			for(int i = 0; i < size; i++) {
				tokenize();
				arr[i] = Long.parseLong(tokenizer.nextToken());
			}
			return arr;
		}
		
		public float[] nextFloatArray(int size) {
			tokenize();
			float[] arr=new float[size];
			for(int i = 0; i < size; i++) {
				tokenize();
				arr[i] = Float.parseFloat(tokenizer.nextToken());
			}
			return arr;
		}

		public double[] nextDoubleArray(int size) {
			tokenize();
			double[] arr=new double[size];
			for(int i = 0; i < size; i++) {
				tokenize();
				arr[i] = Double.parseDouble(tokenizer.nextToken());
			}
			return arr;
		}

		public String[] nextStringArray(int size) throws IOException {
			String[] arr=new String[size];
			for(int i = 0; i < size; i++) 
				arr[i] = reader.readLine();
			return arr;
		}

		public char[] nextCharArray(int size) throws IOException {
			return reader.readLine().toCharArray();
		}
	}

	static class OutputWriter {
		public PrintWriter pw;

		public OutputWriter(OutputStream stream) {
			pw = new PrintWriter(stream);
		}
		
		public void println(Object... obj) {
			if (obj.length == 0) pw.println();
			else {
				String delimiter = (String) obj[obj.length - 1];
				for (int i = 0 ; i < obj.length - 2; i++) {
					pw.print(obj[i]);
					pw.print(delimiter);
				}
				pw.println(obj[obj.length - 2]);
			}
		}

		public void close() {
			pw.close();
		}

		public void flush() {
			pw.flush();
		}

		public void printStringArray(String[] arr) {
			for(int i = 0; i < arr.length; i++)
				pw.println(arr[i]);
		}
		
		public void printBooleanArray(boolean[] arr, int a , int b) {
			for(int i = a; i < b; i++)
				pw.print(arr[i] + " ");
		}

		public void printIntArray(int[] arr, int a , int b) {
			for(int i = a; i < b; i++)
				pw.print(arr[i] + " ");
		}

		public void printLongArray(long[] arr, int a , int b) {
			for(int i = a; i < b; i++)
				pw.print(arr[i] + " ");
		}

		public void printCharArray(char[] arr, int a , int b) {
			for(int i = a; i < b; i++)
				pw.print(arr[i] + " ");
		}

		public void printFloatArray(float[] arr, int a , int b) {
			for(int i = a; i < b; i++)
				pw.print(arr[i] + " ");
		}

		public void printDoubleArray(double[] arr, int a , int b) {
			for(int i = a; i < b; i++)
				pw.print(arr[i] + " ");
		}
		
		public void printIntArrayList(ArrayList<Integer> arr, int a , int b) {
			for(int i = a; i < b; i++)
				pw.print(arr.get(i) + " ");
		}
	}
}