program abc(input,output);
var a,b,c,d,e,f:longint;
begin
assign(input, 'B.in');
assign(output, 'B.out');
reset (input);
rewrite (output);
read(input,a,b,c);
readln(input);
readln(input,d);
read(input,e,f);
d:=a*d;
b:=b+c;
d:=d+b;
d:=d-(e+f);
writeln(output,d);
close (input);
close (output);
end.