#include <stdio.h>

int main(){
  int n, q, i, j, k, x=0, y, z, count;
  int min=0, mid, max;
  int b[50000];
  scanf("%d", &n);
  int s[n];
  for(i=0;i<n;i++)scanf("%d", &s[i]);
  scanf("%d", &q);
  int t[q];
  for(j=0;j<q;j++)scanf("%d", &s[j]);
   for(j=0;j<q;j++){
     mid = q/2;
     max = q;
     while(0){
       if(t[j]<s[0] || t[j]>s[q]) break;
       if(t[j]>s[mid]){
         y = mid;
         mid = (mid + max)/2;
         min = y;
         printf("%d %d %d\n", min, mid, max);
       }
       else if(t[j]<s[mid]){
         z = mid;
         mid = (min + mid)/2;
         max = z;
         printf("%d %d %d\n", min, mid, max);
       }
       else if(t[j]=s[mid]){
         for(k=0,count=0;k<x;k++){
           if(t[j]==b[k])count=1;
         }
         if(count==0){
           b[x]=t[j];
           x++;
         }
         printf("%d %d %d\n", min, mid, max);
         break;
       }
     }
   }
   printf("%d\n", x);
   return 0;
}
