Program HOC24;
const fi='UCLN.inp';
fo='UCLN.ou';
var a,b,c,d,e,f: integer;
t: longint;
function ucln(x,y: integer): integer;
var tg: integer;
begin
while y<>0 do
begin
tg:=x mod y;
x:=y;
y:=tg;
end;
ucln:=x;
end;
f: text;
procedure ip;
begin
assign(f,fi);
reset(f);
readln(f,a,b);
readln(f,c,d);
readln(f,e,f);
close(f);
end;
procedure out;
begin
assign(f,fo);
rewrite(f);
write(f,ucln(a,b)+ucln(c,d)+ucln(e,f));
close(f);
end;
begin
ip;
out;
end.