program chisla_kratni7_1;
var a,b,c,a2,b2,c2,s: integer;
begin
writeln ('vvedit tri chisla');
readln (a,b,c);
s:=0;
a2:= a mod 10;
b2:= b mod 10;
c2:= c mod 10;
if (a mod 7 =0) and (a2=1) then
s:=s+a;
if (b mod 7 =0) and (b2=1) then
s:=s+b;
if (c mod 7 =0) and (c2=1) then
s:=s+c;
writeln (s);
readln
end.