Problem:
Search II

You are given a sequence of n integers S and a sequence of different q integers T. Write a program which outputs C, the number of integers in T which are also in the set S.

Input

In the first line n is given. In the second line, n integers are given. In the third line q is given. Then, in the fourth line, q integers are given.

Output

Print C in a line.

Constraints

Elements in S is sorted in ascending order

n ≤ 100000

q ≤ 50000

0 ≤ an element in S ≤ 109

0 ≤ an element in T ≤ 109

Sample Input 1

5
1 2 3 4 5
3
3 4 1

Sample Output 1

3

Sample Input 2

3
1 2 3
1
5

Sample Output 2

0

Sample Input 3

5
1 1 2 2 3
2
1 2

Sample Output 3

2

Notes

Solution in JAVA (judge verdict: Accepted)

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
	public static void main(String[] args) {

		int suretu_kazu=0;
		int[] suretu;
		int bubun_nokazu=0;
		int[] bubun;
		String moji="";
		String[] srt;
		String[] bbn;
		int gacchi=0;

		BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));

		try {
			moji=bfr.readLine();
			suretu_kazu=Integer.parseInt(moji);
			moji=bfr.readLine();
			srt=moji.split(" ");
			suretu=new int[suretu_kazu];
			for(int i=0; i<suretu_kazu; i++) {
				suretu[i]=Integer.parseInt(srt[i]);
			}
			moji=bfr.readLine();
			bubun_nokazu=Integer.parseInt(moji);
			moji=bfr.readLine();
			bbn=moji.split(" ");
			bubun=new int[bubun_nokazu];
			for(int i=0; i<bubun_nokazu; i++) {
				bubun[i]=Integer.parseInt(bbn[i]);
			}

			int hidari=0;
			int migi=suretu_kazu;
			int mid=0;

			for(int i=0; i<bubun_nokazu; i++) {
				hidari=0;
				migi=suretu_kazu;
				mid=0;
				while(hidari<migi) {
					mid=(hidari+migi)/2;
					if(suretu[mid]==bubun[i]) {		//探したい値と探す配列のまん中の数字と一致した時合致
						gacchi++;
						break;
					}
					else if(bubun[i]<suretu[mid]) {		//真ん中の数字と探したい数字の大小　真ん中のほうが大きいときは　右（MAX）が真ん中
						migi=mid;
					}
					else {				//中央が探すものより小さい時、一番左を大きくする。
						hidari=mid+1;
					}
				}
			}
			System.out.println(gacchi);
		}catch(IOException e) {

		}
	}
}