var N,R,K,S: integer;
begin
read (K,N);
while (R<>K) and (R<>N) do
read(R)
if R>0 then S:=S+R;
end;
write(S)
end.;
var N,R,K,S: integer;
begin
read (K,N);
while (R<>K) and (R<>N) do
begin
read(R)
if R>0 then S:=S+R;
end;
write(S)
end.;