#include <stdio.h>

int main(){
	int i,left, right, mid,key, ans=0,n,q,s[2000],t[2000];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	  scanf("%d",&s[i]);
	scanf("%d",&q);
	for(i=0;i<n;i++)
	  scanf("%d",&t[i]);
	key=t[0];
	i=0;
	left=0;
	right=n;
	while(left<right) {
		mid=(left+right)/2;
		if(s[mid]==key){
		  ans++;
		  break;
		} else if(key<s[mid])
		  right=mid;
		else
		  left=mid+1;
	}
	printf("%d",ans);
	return 0;
}