program staciakampis;
  { 21 u‘davinys }
  type taskas = record
                  x, y : integer;
                end;
  function dbd (x, y : integer) : integer;
    { randa skai‡i— x ir y did‘iausi…j bendr… dalikl }
  begin
    if x = 0
       then dbd := y
       else dbd := dbd (y mod x, x)
  end;  { dbd }

  function max (x, y : integer) : integer;
  begin
    if x > y
       then max := x
       else max := y
  end;

  function taskai (a, b, c, d : taskas) : integer;
    { randa sta‡iakampio viduje esan‡i— tažk— skai‡i— }
    var ilgis, plotis, a1, b1, a2, b2, task, task1, task2 : integer;
  begin
    { randame gaubian‡iojo sta‡iakampio dyd }
    plotis := max (abs (a.x - c.x), abs (b.x - d.x));
    ilgis := max (abs (a.y - c.y), abs (b.y - d.y));
    task := (plotis - 1) * (ilgis - 1);
    { rasime pirmo trikampio kražtines }
    a1 := abs (a.x - b.x);
    b1 := abs (a.y - b.y);
    task1 := (a1  - 1) * (b1 - 1) + dbd (a1, b1) - 1;
    { taip pat ir antro sta‡iakampio }
    a2 := abs (b.x - c.x);
    b2 := abs (b.y - c.y);
    task2 := (a2 - 1) * (b2 - 1) + dbd (a2, b2) - 1;
    taskai := task - task1 - task2;
  end;

  var a, b, c, d : taskas;
begin
  writeln ('­veskite koordinates laikrod‘io rodykl‚s kryptimi:');

  readln (a.x, a.y, b.x, b.y, c.x, c.y, d.x, d.y);
  writeln (taskai (a, b, c, d));
end.