var

a,v,c,b,x:array [1..10000] of longint;
u1,n2,n3,j,n1,n,i,k,u,r:longint;
er:integer;
f,g:text;

i1,i2,j1,j2:string;
begin

assign(f,'punctfix.in');
reset(f);
readln(f,n);
read(f,i1);
readln(f,k);
read(f,i2);

u:=0;
n1:=0;
for i:=1 to length(i1) do
begin
if i1[u]<>' ' then
begin
val(i1[u],a[i],er);
n1:=n1+1;
end else inc(u);
end;

u1:=0;
n2:=0;
for i:=1 to length(i2) do
begin
if i2[u1]<>' ' then
begin
val(i2[u1],b[i],er);
n2:=n2+1;
end else inc(u1);
end;

n3:=1; r:=0;
for i:=1 to n2 do
begin
for j:=1 to n1 do
begin
c[n3]:=b[i]+a[j];
inc(n3);
if c[n3]=n3 then inc(r);
end;
end;

assign(g,'punctfix.out');
rewrite(g);

write(g,r);

close(f);
close(g);
end.


