#include<stdio.h>
int main(void){
   int a[10],b[10];
   int i,j,num,key,found=0;
   scanf("%d",&num);
   printf("\n");
   for(i=0;i<num;i++){
   scanf("%d",&a[i]);}
   printf("\n");
   scanf("%d",&key);
   printf("\n");
   for(j=0;j<key;j++){
   scanf("%d",&b[j]);}
   for(i=0;i<num;i++){
   for(j=0;j<key;j++){
   if(b[j]==a[i]){
   found=1;
break;}}}
if(found==1){
   printf("%d",i+1);}
else
   printf("0");
return 0;
}