var
  f,g:text;
  n,m,i,j,k,p,num:integer;
  a:array[1..15] of integer;
begin
  assign(f,'input.txt');
  assign(g,'output.txt');
  reset(f);
  rewrite(g);
  readln(f,n,m);
  for i:=1 to n do read(f,a[i]);
  p:=0;
  num:=1;
  for i:=1 to m do
      begin
        read(f,k);
        for j:=1 to n do
           if a[j]=k then p:=p+1;
        if (p=n) or (m-i<n-p) then
          begin
           num:=i;
           break;
          end
      end;
  writeln(g,num);    
  close(f);
  close(g);

end.
