Valera the horse lives on a plane. The Cartesian coordinate system is defined on this plane. Also an infinite spiral is painted on the plane. The spiral consists of segments: [(0, 0), (1, 0)], [(1, 0), (1, 1)], [(1, 1), ( - 1, 1)], [( - 1, 1), ( - 1,  - 1)], [( - 1,  - 1), (2,  - 1)], [(2,  - 1), (2, 2)] and so on. Thus, this infinite spiral passes through each integer point of the plane.Valera the horse lives on the plane at coordinates (0, 0). He wants to walk along the spiral to point (x, y). Valera the horse has four legs, so he finds turning very difficult. Count how many times he will have to turn if he goes along a spiral from point (0, 0) to point (x, y).

The first line contains two space-separated integers x and y (|x|, |y| ≤ 100).

Print a single integer, showing how many times Valera has to turn.

Var x,y,x1,y1,j,i,l,k:longint;
    a:array[-1001..1001,-1001..1001] of longint;
 begin
   read(x1,y1);
   a[x,y]:=0;
   l:=0;
   k:=1;
   for i:=1 to 200 do
    begin
      for j:=1 to k do
       begin
         a[x+j,y]:=l;
       end;
      l:=l+1;
      x:=x+k;
      for j:=1 to k do
       begin
         a[x,y+j]:=l;
       end;
      l:=l+1;
      y:=y+k;
      k:=k+1;
      for j:=1 to k do
       begin
         a[x-j,y]:=l;
       end;
      l:=l+1;
      x:=x-k;
      for j:=1 to k do
       begin
         a[x,y-j]:=l;
       end;
      l:=l+1;
      y:=y-k;
      k:=k+1;
    end;
   writeln(a[x1,y1]);
 end.

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var x,y : integer;
    xt,yt : integer;
    count : integer;
    l,r,u,d,flag : boolean;
    razdva, len,i : integer;
begin
Readln(x,y);
count := 0;

l:=false;
u:=false;
d:=false;
r:=true;

xt:=0;
yt:=0;

razdva := 0;
len := 1;
flag := false;

IF (x = 0) and (y = 0) Then
Begin
writeln('0');
end
else
Begin

while not flag do
  begin

    // Право
    if r then
      begin
        for i:=1 to len do
          begin
          inc(xt);
            if (xt = x) and (yt = y) then flag := true;
          end;
        r := false;
        u := true;

        inc(razdva);
          if razdva = 2 then
            begin
              inc(len);
              razdva := 0;
            end;
        inc(count);
      end
      else
    // Верх
    if u then
      begin
        for i:=1 to len do
          begin
          inc(yt);
            if (xt = x) and (yt = y) then flag := true;
          end;
        u := false;
        l := true;

        inc(razdva);
          if razdva = 2 then
            begin
              inc(len);
              razdva := 0;
            end;
        inc(count);
      end
      else
    // Лево
    if l then
      begin
        for i:=1 to len do
          begin
          dec(xt);
            if (xt = x) and (yt = y) then flag := true;
          end;
        l := false;
        d := true;

        inc(razdva);
          if razdva = 2 then
            begin
              inc(len);
              razdva := 0;
            end;
        inc(count);
      end
      else
    // Низ
    if d then
      begin
        for i:=1 to len do
          begin
          dec(yt);
            if (xt = x) and (yt = y) then flag := true;
          end;
        d := false;
        r := true;

        inc(razdva);
          if razdva = 2 then
            begin
              inc(len);
              razdva := 0;
            end;
        inc(count);
      end;

    end;

writeln(count-1);
end;

end.

program p1;
var x,y,smer,sol:integer; x1,y1:longint;
begin
  readln(x,y);
  x1:=0; y1:=0; smer:=2;
  while (x1<>x) or (y1<>y) do
  begin
    if (x1=y1) and (x1>0) then begin inc(sol); smer:=4; end;
    if (x1+y1=1) and (x1>0) then begin inc(sol); smer:=3; end;
    if (x1=y1) and (x1<0) then begin inc(sol); smer:=2; end;
    if (x1+y1=0) and (x1<0) then begin inc(sol); smer:=1; end;
    if smer=1 then dec(y1)
     else if smer=2 then inc(x1)
      else if smer=3 then inc(y1)
       else dec(x1);
  end;
  writeln(sol);
end.

var x,y:longint;
begin
read (x,y);
if (y=0) and (x=0) then write ('0');
if (y>x) and (-x<=y) then write (4*y-2);
if (y>=x) and (-x>y) then write (-4*x-1);
if (y<x) and (y<=-x+1) then write (-4*y);
if (y<=x) and (y>-x+1) then write (4*x-3)

end.

program apoint;
var
  xxx,yyy,xx,yy:longint;
  x,y,g:longint;
procedure change(l:longint);
begin
  if l=2 then
  begin
    xx:=xxx;
    yy:=yyy;
    xxx:=xx;
    yyy:=-yy;
  end;
  if l=3 then
  begin
    xx:=xxx;
    yy:=yyy;
    xxx:=-xx+1;
    yyy:=yy;
  end;
  if l=0 then
  begin
    xx:=xxx;
    yy:=yyy;
    xxx:=xx;
    yyy:=-yy+1;
  end;
  if l=1 then
  begin
    xx:=xxx;
    yy:=yyy;
    xxx:=-xx;
    yyy:=yy;
  end;
end;
begin
  readln(x,y);
  if (x=0) and(y=0) then
  begin
    writeln(0);
  end
  else if (x=1)and(y=0) then
  begin
    writeln(0);
  end
  else if (x=1)and(y=1) then
  begin
    writeln(1);
  end
  else
  begin
    xx:=1;
    yy:=1;
    xxx:=-1;
    yyy:=1;
    g:=2;

    while 1=1 do
    begin
      if (xxx=xx)and(xx=x)and(((y<=yy)and(y>=yyy))or((y<=yyy)and(y>=yy))) then
      begin
        writeln(g);
        exit;
      end;
      if (yy=yyy)and(yy=y)and(((x<=xx)and(x>=xxx))or((x<=xxx)and(x>=xx))) then
      begin
        writeln(g);
        exit;
      end;
      change(g mod 4);
      inc(g);
    end;
  end;
end.

var
    x,y,nowx,nowy,nextx,nexty,tot:longint;

function onsegment(x1,y1,x2,y2,x3,y3:longint):boolean;
begin
    if (x1=x3) and (x2=x3) then
        exit((y3-y2)*(y1-y3)>=0)
    else
        if (y1=y3) and (y2=y3) then
            exit((x3-x2)*(x1-x3)>=0);
    exit(false);
end;

begin
    readln(x,y);
    tot:=0;
    nowx:=0;
    nowy:=0;
    nextx:=1;
    nexty:=0;
    while not onsegment(nowx,nowy,nextx,nexty,x,y) do
    begin
        nowx:=nextx;
        nowy:=nexty;
        if tot mod 4=0 then
            nexty:=-nexty+1;
        if tot mod 4=1 then
            nextx:=-nextx;
        if tot mod 4=2 then
            nexty:=-nexty;
        if tot mod 4=3 then
            nextx:=-nextx+1;
        inc(tot);
    end;
    writeln(tot);
end.

program P279A;
const   fin='';
        fou='';
var x,y:shortint;
    count:integer;
    fi,fo:text;

procedure   enter();
    begin
    assign(fi,fin);reset(fi);
    read(fi,x,y);
    close(fi);
    end;

function getmin(x,y:integer):integer;
   begin
   if(x<y) then
      exit(x)
   else
      exit(y);
   end;

function getmax(x,y:longint):longint;
   begin
   if (x>y) then
      exit(x)
   else
      exit(y);
   end;

procedure   process();
    var tmp,tmp2,tmp3,x0,y0:integer;
    begin
    tmp:=0;
    tmp2:=0;
    x0:=0;
    y0:=0;
    count:=-1;
   while (x0<>x) or (y0<>y) do
        begin
        if (tmp2=0) then inc(tmp);
        if (tmp2=0) then
            begin
         tmp3:=x0;
            if (odd(tmp)) then
                x0:=x0+tmp
            else
                x0:=x0-tmp;
         if (y=y0)
         and (x<getmax(tmp3,x0))
         and (x>getmin(tmp3,x0)) then
            begin
            inc(count);
            break;
            end;
            inc(tmp2);
            end
        else
            if (tmp2=1) then
                begin
            tmp3:=y0;
                if (odd(tmp)) then
                    y0:=y0+tmp
                else
                    y0:=y0-tmp;
            if (x=x0)
            and (y<getmax(tmp3,y0))
            and (y>getmin(tmp3,y0)) then
               begin
               inc(count);
               break;
               end;
                inc(tmp2);
            end;
        if (tmp2=2) then
           tmp2:=0;
        inc(count);
        end;
    assign(fo,fou);rewrite(fo);
   if (count<0) then
      write(fo,0)
   else
       write(fo,count);
    close(fo);
    end;

begin
    enter();
    process();
end.

{$APPTYPE CONSOLE}

uses
  SysUtils;
var  m,n,i,j,a,c,x,y,b:longint;

begin
//  assignfile(input,'INPUT.TXT'); reset(input);
//  assignfile(output,'OUTPUT.TXT'); rewrite(output);
  read(x,y);  i:=0; j:=0; m:=0; b:=0;

  while true do
  begin

    inc(m); a:=j; c:=i;

    if m mod 2=1 then inc(b);

    if m mod 4=1 then inc(j,b);
    if m mod 4=2 then inc(i,b);
    if m mod 4=3 then dec(j,b);
    if m mod 4=0 then dec(i,b);

    if (a<=j) and (c<=i) then
    if (a<=x) and (x<=j) and (c<=y) and (y<=i) then break;

    if (a>=j) and (c<=i) then
    if (j<=x) and (x<=a) and (c<=y) and (y<=i) then break;

    if (a<=j) and (c>=i) then
    if (a<=x) and (x<=j) and (i<=y) and (y<=c) then break;

    if (a>=j) and (c>=i) then
    if (j<=x) and (x<=a) and (i<=y) and (y<=c) then break;

  end;

  write(m-1);
  readln; readln;
end.

const
 napy:array[1..4]of longint=(0,1,0,-1);
 napx:array[1..4]of longint=(1,0,-1,0);
var
 a:array[0..1000]of longint;
 nap,x1,y1,z,g,x,y,pov,pov1,i,j,n,m:longint;

 function mi(a,b:longint):longint;
 begin
  if a<b then mi:=a else mi:=b;
 end;

 function ma(a,b:longint):longint;
 begin
  if a>b then ma:=a else ma:=b;
 end;

begin
{ assign(input,'a.in');
 reset(input);
 assign(output,'a.out');
 rewrite(output);}
 x1:=0;
 y1:=0;
 g:=1;
 z:=0;
 nap:=1;
 readln(x,y);
 while 0=0 do
 begin
  if nap=1 then
  begin
   for j:=x1 to x1+g do
   if (x=j)and(y=y1) then
   begin
    writeln(pov);
    halt;
   end;
   x1:=x1+g;
  end;
  if nap=2 then
  begin
   for j:=y1 to y1+g do
   if (y=j)and(x=x1) then
   begin
    writeln(pov);
    halt;
   end;
   y1:=y1+g;
  end;
  if nap=3 then
  begin
   for j:=x1 downto x1-g do
   if (x=j)and(y=y1) then
   begin
    writeln(pov);
    halt;
   end;
   dec(x1,g);
  end;
  if nap=4 then
  begin
   for j:=y1 downto y1-g do
   if (x=x1)and(y=j) then
   begin
    writeln(pov);
    halt;
   end;
   y1:=y1-g;
  end;
  inc(z);
  inc(pov);
  if z=2 then
  begin
   z:=0;
   inc(g);
  end;
  inc(nap);
  if nap>4 then nap:=1;
 end;
end.

 procedure qSort(l,r:longint);
 var
  i,j,m,p:longint;
 begin
  i:=l;
  j:=r;
  m:=a[l+random(r-l+1)];
  repeat
   while a[i]<m do inc(i);
   while a[j]>m do dec(j);
   if i>j then break;
   p:=a[i];
   a[i]:=a[j];
   a[j]:=p;
   inc(i);
   dec(j);
  until i>j;
  if i<r then qSort(i,r);
  if l<j then qSort(l,j);
 end;

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  x, y, x1, y1, x2, y2, t, ans, dx, dy: integer;

begin
  //reset(input, 'input.in');
  //rewrite(output, 'output.out');
  readln(x, y);
  if (x = 0) and (y = 0) then begin
    writeln('0');
    exit;
  end;
  ans := 0;
  dx := 0;
  dy := 0;
  x1 := 0; y1 := 0;
  t := 1;
  while true do begin
    y2 := y1;
    x2 := x1;
    if t = 1 then begin
      t := 2;
      dx := dx + 1;
      x1 := x1 + dx;
      inc(ans);
    end else if t = 2 then begin
      t := 3;
      dy := dy + 1;
      y1 := y1 + dy;
      inc(ans);
    end else if t = 3 then begin
      t := 4;
      dx := dx + 1;
      x1 := x1 - dx;
      inc(ans);
    end else begin
      t := 1;
      dy := dy + 1;
      y1 := y1 - dy;
      inc(ans);
    end;
    if ((x - x1) * (x - x2) <=0 ) and ((y - y1) * (y - y2) <=0) then begin
      writeln(ans - 1);
      exit;
    end;
  end;
end.

var x,y,i,j,v,v2:integer; a:array[-101..101,-101..101]of integer;
begin
readln(x,y);
for i:=1 to 100 do
  begin
    j:=-i+1;
    a[i,j]:=v;
    inc(v);
    for j:=-i+2 to i do a[i,j]:=v;
    inc(v);
    a[-i,j]:=v;
    inc(v);
    for j:=i-1 downto -i do a[-i,j]:=v;
    inc(v);
  end;
v:=1;
for i:=1 to 100 do
  begin
    j:=i;
    a[j,i]:=v;
    inc(v);
    for j:=i-1 downto -i do a[j,i]:=v;
    inc(v);
    a[j,-i]:=v;
    inc(v);
    for j:=-i+1 to i+1 do a[j,-i]:=v;
    inc(v);
  end;
writeln(a[x,y]);
end.

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils,math;

type point = record x,y:integer; end;

{Procedure QSort(m, t: Integer);
Var i, j, x, w: Integer;
Begin
  i:=m; j:=t; x:=A[random(t-m+1)+m];
  Repeat
    While A[i]<x Do Inc(i);
    While A[j]>x Do Dec(j);
    If i<=j Then Begin
      w:=A[i]; A[i]:=A[j]; A[j]:=w;
      Inc(i); Dec(j);
    End
  Until i>j;
  If m<j Then QSort(m, j);
  If i<t Then QSort(i, t);
End;   }

           {
function gcd(a,b:integer):integer;
begin
if b=0 then gcd:=a
       else gcd:=gcd(b,a mod b);
end;

function search(str:string):integer;
var i,x:integer;
begin
x:=0;
for i:=1 to  do
 if team[i]=str then begin x:=i; break; end;
search:=x;
end;

}

var x,y,i,j,ans,t:integer;
    a:array[-100..100,-100..100] of boolean;

begin
readln(x,y);
ans:=1000*1000*1000;
if (x=0) and (y=0) then begin writeln('0'); readln; halt; end;
if (x=1) and (y=0) then begin writeln('0'); readln;halt; end;

if (y<0) and (x>=y) and (x<=-y+1) then begin ans:=min(ans,-y*4); end;
if (x>0) and (y>=-x+1) and (y<=x) then begin ans:=min(ans,x*4-3);  end;
if (y>0) and (x>=-y) and (x<=y) then begin ans:=min(ans,y*4-2);  end;
if (x<0) and (y>=x) and (y<=-x) then begin ans:=min(ans,-x*4-1);  end;
write(ans);
readln;

end.

{$o-}
program abc;
var
  x,y: integer;
begin
  readln(x,y);
  if (x = 0) and (y = 0) then
    writeln(0)
  else if (y > x) and (y >= -x) then
    writeln(4*y-2)
  else if (y < -x) and (y >= x) then
    writeln(-4*x-1)
  else if (y < x) and (y <= -x+1) then
    writeln(-4*y)
  else
    writeln(4*x-3);
end.

{$R+ Q+ I+}
{$apptype console}
uses
    sysutils,math;
var
   x,y,l,r,i,k,j : integer;
begin
    read(x,y);
    if (x = 0) and (y = 0) then begin
        write(0);
        halt;
    end;
    l := 0;
    r := 0;
    i := 1;
    k := 0;
    while (l <> x) or (r <> y) do begin
           l := l + i;
           inc(k);
           for j := l - i to l do
               if (j = x) and (r = y) then begin
                   write(k-1);
                   halt;
               end;
           r := r + i;
           inc(k);
           for j := r - i to r do
               if (l = x) and (j = y) then begin
                   write(k-1);
                   halt;
               end;
           inc(i);
           dec(l,i);
           inc(k);
           for j := l to l + i do
               if (j = x) and (r = y) then begin
                   write(k-1);
                   halt;
               end;
           dec(r,i);
           inc(i);
           inc(k);
           for j := r to r + i do
               if (l = x) and (j = y) then begin
                   write(k-1);
                   halt;
               end;
    end;
    writeln(k-1);

end.

program contest;

{$APPTYPE CONSOLE}
{$R+ ,Q+ ,I+}

uses
  SysUtils;

var
  n,i,j,k,s,t,x,m,y,ans: integer;
  c,a,p: array[1..100]of integer;
begin
  read(n,m);
  x:=0;
  y:=0;
  ans:=0;
  j:=0;
  t:=0;
  if (n=x) and (m=x) then begin
    write(ans);
    halt;
  end;
  while true do begin
    //////////////////////////////////
    inc(t);
    inc(x,t);
    for i:=j to x do begin

      if (i=n) and (y=m) then begin
        write(ans);
        halt;
      end;
    end;
    inc(ans);
    inc(y,t);
    for i:=j to y do begin

      if (x=n) and (i=m) then begin
        write(ans);
        halt;
      end;
    end;
    inc(ans);
    //////////////////////////////////
    j:=x;
    inc(t);
    dec(x,t);
    for i:=j downto x do begin

      if (i=n) and (y=m) then begin
        write(ans);
        halt;
      end;
    end;
    inc(ans);
    dec(y,t);
    for i:=j downto y do begin

      if (x=n) and (i=m) then begin
        write(ans);
        halt;
      end;
    end;
    inc(ans);
    j:=x;
  end;
  write(ans+1-1);
end.

var n,i,k,p,x,y,j,m,t,max:longint;
begin
read(x,y);
if abs(x)>abs(y) then max:=abs(x) else max:=abs(y);
if (x=0) and (y=0) then writeln(0) else
if (x=max) and (y=-max+1) then writeln(4*max-4) else
if (x=max) and (y<>-max) then writeln(4*max-3) else
if y=max then writeln(4*max-2) else
if x=-max then writeln(4*max-1) else writeln(4*max);
end.

{$APPTYPE CONSOLE}
{$R+}
uses SysUtils, Math;

var
  a: array[-100..1000] of integer;
  x, y, i, j, n, k, l, inn, jnn: integer;

begin
{$IFNDEF ONLINE_JUDGE}
  Reset(input, 'input.txt');
  Rewrite(output, 'output.txt');
{$ENDIF}
  read(x, y);
  i := 0;
  j := 0;
  k := 1;
  l := 0;
  if (i = x) and (j = y) then
    begin
      write(l);
      Exit;
    end;
  while (i <> x) or (y <> j) do
  begin
  if (i = x) and (j = y) then
    begin
      write(l);
      Exit;
    end;
    inn := i;
    while ((i <> x) or (y <> j)) and (Abs(i - inn) <> k) do
      inc(i);

    if (i = x) and (j = y) then
    begin
      write(l);
      Exit;
    end;
    inc(l);
    jnn := j;
    while ((i <> x) or (y <> j)) and (Abs(j - jnn) <> k) do
      inc(j);

    if (i = x) and (j = y) then
    begin
      write(l);
      Exit;
    end;
    inc(l);
    inc(k);

    inn := i;
    while ((i <> x) or (y <> j)) and (Abs(i - inn) <> k) do
      dec(i);

    if (i = x) and (j = y) then
    begin
      write(l);
      Exit;
    end;
    inc(l);

    jnn := j;
    while ((i <> x) or (y <> j)) and (Abs(j - jnn) <> k) do
      dec(j);

    if (i = x) and (j = y) then
    begin
      write(l);
      Exit;
    end;
    inc(l);
    inc(k);
  end;

end.

var
  x,y,xx,yy,ans,i,uk : longint;

begin
 // assign(input,'input.txt'); reset(input);
 // assign(output,'output.txt'); rewrite(output);

  readln(x,y);

  xx:=0; yy:=0;
  uk:=1;
  ans:=0;
  i:=1;
  while true do begin
    if i mod 2=1 then
    begin
      inc(ans);
      if (yy=y) and (x>=xx) and (x<=xx+uk) then break;
      inc(ans);
      xx:=xx+uk;
      if (xx=x) and (y>=yy) and (y<=yy+uk) then break;
      yy:=yy+uk
    end
    else
    begin
      inc(ans);
      if (yy=y) and (x>=xx-uk) and (x<=xx) then break;
      inc(ans);
      xx:=xx-uk;
      if (xx=x) and (y>=yy-uk) and (y<=yy) then break;
      yy:=yy-uk
    end;
    inc(uk);
    inc(i);
  end;

  writeln(ans-1);
end.

const dx:array[0..3] of integer = (1,0,-1,0);
      dy:array[0..3] of integer = (0,1,0,-1);
var ans,q,w,x,y,i,l,k,j,m,n:longint;
    a:array[-200..200,-200..200] of boolean;
begin
read(q,w);
x:=0;
y:=0;
i:=0;
ans:=0;
while true do
begin
if (x=q) and (y=w) then break;
a[x,y]:=true;
l:=(i+1) mod 4;
if (x=0) and (y=0) then
  begin x:=x+dx[i]; y:=y+dy[i] end else
  begin
   if a[x+dx[l],y+dy[l]]=false then begin i:=l; inc(ans); end;
   x:=x+dx[i];
   y:=y+dy[i];
  end;
end;
writeln(ans);
end.

const
  ds: array [0..3, 0..1] of longint = ((1, 0), (0, 1), (-1, 0), (0, -1));

var
  x, y, x0, y0, d, l, ll, c: longint;

begin
  read(x, y);
  x0 := 0; y0 := 0;

  d := 0; l := 1; ll := 1; c := 0;

  while (x0 <> x) or (y0 <> y) do begin
    if ll = 0 then begin
      d := (d+1) mod 4;
      inc(c);
    end else
    if ll = -l then begin
      inc(l);
      ll := l;
      d := (d+1) mod 4;
      inc(c);
    end;
    x0 := x0 + ds[d, 0];
    y0 := y0 + ds[d, 1];
    dec(ll);
  end;

  writeln(c);
end.

program Project1;
var
  x,y,x0,y0,kol:int64;
  i,j:longint;
  flag:boolean;
 //привет саня!
 procedure d;
 begin
  { assign(input,'input.txt');reset(input);
   assign(output,'output.txt');rewrite(output);}
   i:=1;
   flag:=true;
  while (x0<>x) or (y0<>y) do begin
    j:=1;
   while flag and ((x0<>x) or (y0<>y)) and (j<=i) do  begin
   inc(x0);
    if  (x0=x) and (y0=y) then flag:=false;
    inc(j);
   end;
   if flag then inc(kol);
   j:=1;
   while flag and ((x0<>x) or (y0<>y)) and (j<=i) do begin
   inc(y0);
   if  (x0=x) and (y0=y) then flag:=false;
    inc(j);
   end;
   if flag then inc(kol);
   inc(i);

   j:=1;
   while flag and (j<=i) and ((x0<>x) or (y0<>y)) do begin

   dec(x0);
   if  (x0=x) and (y0=y) then flag:=false;
    inc(j);
    end;
   if flag then inc(kol);
   j:=1;
   while flag and (j<=i) and ((x0<>x) or (y0<>y)) do begin
   dec(y0);
   if  (x0=x) and (y0=y) then flag:=false;
    inc(j);
   end;
   if flag then inc(kol);

   inc(I);

  end;
 end;

begin
// assign(input,'input.txt');reset(input);
// assign(output,'output.txt');rewrite(output);

  readln(x,y);

  x0:=0;
  y0:=0;

  d;
  write(kol);

end.

function mog(n,m : longint) : integer;
begin
if m<0 then m:=m*-1;
if n<0 then n:=n*-1;
if n>=m then mog:=1;
if m>n then mog:=2;
if n=m then mog:=0;
end;
var i,i2,n,m,x,y,ans : longint;
        c : char;
begin
readln(x,y);
if (x<0) and ( (mog(x,y)=1) or (mog(x,y)=0) ) and (y<>x*-1) then c:='l';
if (x>0) and ( (mog(x,y)=1) or (mog(x,y)=0) ) and (y<>(x-1)*-1) and (y<>x*-1) then c:='r';
if (y>0) and ( (mog(x,y)=2) or (mog(x,y)=0) ) and (x<>y) then c:='u';
if (y<0) and ( ( (mog(x,y)=2) or (mog(x,y)=0) ) or (mog(x,y)=1) and (x=(y*-1)+1) ) and (x<>y) then c:='d';

if c='r' then ans:=x*4-3;
if c='l' then ans:=(x*-1)*4-1;
if c='d' then ans:=(y*-1)*4;
if c='u' then ans:=y*4-2;
writeln(ans);
readln;
end.

program ll;
 const dd=1000000007;
 var x,y,b,c,n,m,j,t,t2,k,i:longint;{F:BOOLEAN;{z,x,y:array[-1..255]of int64;
 u:array[0..22501]of longint;r1,r2:real;x:array[0..100003]of longint;{real;
 y:array[0..500]of int64;}

 begin
{assign(input,'input.txt');reset(input);
sassign(output,'output.txt');rewrite(output);}
read(x,y);
if (y=0) and (x=0) then begin write(0);halt; end;
if (y>-x+1) and (y<=x) then begin write(x*4-3);halt; end;
if (y>x) and (y>=-x) then begin write(y*4-2);halt; end;
if (y<-x) and (y>=x) then begin write(-x*4-1);halt; end;
 write(-y*4);halt;
 end.

var step,pos,ans,kol,adx,ady,x,y,xc,yc:longint;
    ad:array[1..4,1..2] of longint;

    function ok(x1,y1,x2,y2:longint):boolean;
     begin
      exit((x1<>x2) or (y1<>y2));
     end;

 begin
  readln(x,y);
  ad[1][1]:=1;
  ad[1][2]:=0;
  ad[2][1]:=0;
  ad[2][2]:=1;
  ad[3][1]:=-1;
  ad[3][2]:=0;
  ad[4][1]:=0;
  ad[4][2]:=-1;
  while ok(x,y,xc,yc) do
   begin
    inc(kol);
    step:=kol;
    inc(pos);
    if pos=5 then pos:=1;
    while step>0 do
     begin
      if not ok(x,y,xc,yc) then begin writeln(ans); halt; end;
      dec(step);
      xc:=xc+ad[pos][1];
      yc:=yc+ad[pos][2];
     end;
    if not ok(x,y,xc,yc) then begin writeln(ans); halt; end;
    inc(ans);
    step:=kol;
    inc(pos);
    if pos=5 then pos:=1;
    while step>0 do
     begin
      if not ok(x,y,xc,yc) then begin writeln(ans); halt; end;
      dec(step);
      xc:=xc+ad[pos][1];
      yc:=yc+ad[pos][2];
     end;
    if not ok(x,y,xc,yc) then begin writeln(ans); halt; end;
    inc(ans);
   end;
   writeln(ans);
  end.

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
x, y, N:integer;
begin
read(x); readln(y);
if (y>0)and(y>=abs(x))and(y<>x) then N:=2+(y-1)*4  else
if (x<0) and (abs(x)>=abs(y)) and (abs(x)<>y) then N:=3+(abs(x)-1)*4  else
if (x>0) and (((y<0)and((x-1)>abs(y))) or (y>=0)) then N:=1+(x-1)*4 else
N:=abs(y)*4;
if ((x=0)and(y=0))or((x=1)and(y=0)) then N:=0;
write (N);
readln;
end.

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils, Math;

var i, n,x1,y1,x,y,vx,vy,l,c,ans,k : integer;

procedure ok;
begin
  if (x1=x) and (y1=y) then begin
    write(ans);
    halt;
  end;
end;

begin
 // reset(input, 'input.txt');
 // rewrite(output, 'output.txt');
  read(x,y);
  x1:=0;
  y1:=0;
  vx:=1;
  vy:=0;
  ans:=0;
  c:=1;
  k:=0;
  l:=0;
  while true do begin
    ok;
    x1:=x1+vx;
    y1:=y1+vy;
    ok;
    inc(k);
    if k=c then begin
      inc(ans);
      k:=0;
      if (vx=1) and (vy=0) then begin
        vx:=0;
        vy:=1;
      end else
      if (vx=0) and (vy=1) then begin
        vx:=-1;
        vy:=0;
      end else
      if (vx=-1) and (vy=0) then begin
        vx:=0;
        vy:=-1;
      end else
      if (vx=0) and (vy=-1) then begin
        vx:=1;
        vy:=0;
      end;
      inc(l);
    end;
    if l=2 then begin
      l:=0;
      inc(c);
    end;

  end;
  write(ans);
end.

var i,j,l,k,t,p,x,y,ans,z:longint;
    f:boolean;
begin
  readln(x,y);
  i:=0; j:=0;
  k:=1; t:=1; p:=1;
  while ((i<>x) or (j<>y)) do
  begin
    inc(z);
    f:=false;
    if (p=1) and (not f) then begin inc(i); dec(t); f:=true; end;
    if (p=2) and (not f) then begin inc(j); dec(t); f:=true; end;
    if (p=3) and (not f) then begin dec(i); dec(t); f:=true; end;
    if (p=4) and (not f) then begin dec(j); dec(t); f:=true; end;
    if (t=0) then
    begin
      inc(l);
      if (p=1) then p:=2 else
      if (p=2) then p:=3 else
      if (p=3) then p:=4 else p:=1;
      if (t=0) and (l<2) then
      begin
        t:=k;
        if (i<>x) or (j<>y) then inc(ans);
      end else
      begin
        if (i<>x) or (j<>y) then inc(ans);
        inc(k);
        t:=k;
        l:=0;
      end;
    end;
  end;
  writeln(ans);
end.

var
 x,y:integer;
Begin
 read(x,y);
 if ((x=0)or(x=1))and(y=0) then Begin write(0); exit; end;
 if (x=y)and(x>0)and(y>0) then Begin write(2*(2*x-1)-1); exit; end;
 if (abs(x)=y)and(x<0) then Begin write(2*(2*abs(x)-1)); exit end;
 if x=y then Begin write(2*(2*abs(x))-1); exit; end;
 if ((abs(y)=(x-1))or(abs(y)=x))and(y<0) then Begin write(2*(2*abs(y))); exit; end;
 if (y>abs(x))and(y>0) then Begin write(2*(2*y-1)); exit; end;
 if (abs(x)>abs(y))and(x<0) then Begin write(2*(2*abs(x))-1); exit; end;
 if (abs(y)>abs(x))and(y<0) then begin write(2*(2*abs(y))); exit; end;
 if (x>y)and(x>0) then begin write(2*(2*x-1)-1); exit end;
end.

program Project2;

{$APPTYPE CONSOLE}

uses   SysUtils;
var x0,y0, x,y,xk,yk: Integer;
   p,n,i,j,t, otv: integer;
   f: Boolean;

begin
  { TODO -oUser -cConsole Main : Insert code here }
  Readln(xk,yk);
  p:=0;
  x0:=0;  y0:=0;
  x:=x0; y:=y0;
  f:= True;
  t:=1; otv:=0;
  while f   do
  begin
    if (x=xk)and(y=yk) then begin  otv:=p; f:=False; end;

     for i:=1 to t do
     begin
        Inc(x);
        if (x=xk)and(y=yk) then begin  otv:=p; f:=False; end;
     end;
     Inc(p);
     for i:=1 to t  do
     begin
        Inc(y);
        if (x=xk)and(y=yk) then begin otv:=p;  f:=False; end;
     end;
     Inc(p);  Inc(t);

     for i:=1 to t do
     begin
        Dec(x);
        if (x=xk)and(y=yk) then begin otv:=p;   f:=False; end;
     end;
     Inc(p);
     for i:=1 to t  do
     begin
        dec(y);
        if (x=xk)and(y=yk)   then  begin otv:=p;    f:=False; end;
     end;
     Inc(p);   Inc(t);

  end;

 Writeln(otv);
end.

var x,y: integer;
begin
  readln(x,y);
  if (x=0)and(y=0) then writeln(0)
                   else
  if (x>y)and(x<=1-y) then writeln(-y*4)
                      else
  if (y>-x)and(y<=x) then writeln((x-1)*4+1)
                     else
  if (x>=-y)and(x<y) then writeln((y-1)*4+2)
                     else writeln((-x-1)*4+3)
end.

var x,y,i,j,v,v2:integer; a:array[-101..101,-101..101]of integer;
begin
readln(x,y);
for i:=1 to 100 do
  begin
    j:=-i+1;
    a[i,j]:=v;
    inc(v);
    for j:=-i+2 to i do a[i,j]:=v;
    inc(v);
    a[-i,j]:=v;
    inc(v);
    for j:=i-1 downto -i do a[-i,j]:=v;
    inc(v);
  end;
v:=1;
for i:=1 to 100 do
  begin
    j:=i;
    a[j,i]:=v;
    inc(v);
    for j:=i-1 downto -i do a[j,i]:=v;
    inc(v);
    a[j,-i]:=v;
    inc(v);
    for j:=-i+1 to i+1 do a[j,-i]:=v;
    inc(v);
  end;
writeln(a[x,y]);
end.

const LEFT = 1;
      RIGHT = 2;
      UP = 3;
      DOWN = 4;
      nxt : array[1..4] of longint = (down,up, left, right);
      step : array[1..4,1..2] of longint = ((-1,0),(1,0),(0,1),(0,-1));
var
 n,i,j,x,y,now,next,fx,fy,ans : longint;
 a : array[0..400,0..400] of longint;
begin
 readln(fx,fy);

 x := 200;
 y := 200;
 fx := fx + 200;
 fy := fy + 200;

 now := 1;
 next := RIGHT;

 while not ((x = fx) and (y = fy)) do begin
  a[x,y] := now;
  x := x + step[next,1];
  y := y + step[next,2];
  if (x = fx) and (y = fy) then break;
  if a[x + step[nxt[next],1], y + step[nxt[next],2]] = 0 then begin next := nxt[next]; inc(ans); end;

  inc(now);
 end;

 writeln(ans);

end.

var
 tmp,left,x,y,x1,y1,i:longint;
begin
 readln(x,y);
 if (x=0)and(y=0) then begin writeln(0); halt; end;
 x1:=0;y1:=0;
 while i=0 do
  begin
   tmp:=x1;
   x1:=abs(x1)+1;
   if (y=y1)and((tmp<=x)and(x<=x1)) then begin writeln(left);halt; end;
   inc(left);
   tmp:=y1;
   y1:=abs(y1)+1;
   if (x=x1)and((tmp<=y)and(y<=y1)) then begin writeln(left); halt; end;
   inc(left);
   tmp:=x1;
   x1:=-x1;
   if (y=y1)and((tmp>=x)and(x>=x1)) then begin writeln(left);halt; end;
   inc(left);
   tmp:=y1;
   y1:=-y1;
   if (x=x1)and((tmp>=y)and(y>=y1)) then begin writeln(left);halt; end;
   inc(left);
  end;
end.

Var x,y,x1,y1,k,s,res,i:longint;
Begin
Readln(x,y);
If ((x=0) or (x=1)) and (y=0) Then Begin Writeln(0); Halt; End;
x1:=1; y1:=0;
s:=0;
k:=1;
res:=1;
While true do
 Begin
  If s=0 Then Begin For i:=1 to k do Begin inc(y1); If (x1=x) and (y=y1) Then Begin Writeln(res); Halt; End; End; inc(s); inc(res); inc(k); End;
  If s=1 Then Begin For i:=1 to k do Begin dec(x1); If (x1=x) and (y=y1) Then Begin Writeln(res); Halt; End; End; inc(s); inc(res); End;
  If s=2 Then Begin For i:=1 to k do Begin dec(y1); If (x1=x) and (y=y1) Then Begin Writeln(res); Halt; End; End; inc(s); inc(res); inc(k); End;
  If s=3 Then Begin For i:=1 to k do Begin inc(x1); If (x1=x) and (y=y1) Then Begin Writeln(res); Halt; End; End; inc(res); End;
  s:=s mod 3;
 End;
End.

uses math;
var
  len,ans,i,j,ix,jy,x,y:longint;

procedure pr(el:longint);
begin
  writeln(el);
  halt;
end;

begin
  readln(x,y);
  if (x= 0) and (y= 0) then begin
    writeln(0);
    halt;
  end;
  i:=0;
  j:=0;
  for len:=1 to 1000 do begin
    if len mod 2 = 1 then begin
      //r
        ix:=i+len;
        jy:=j;
        if (y=j) and (x > i) and (x <= ix) then pr(ans);
        inc(ans);
        i:=ix;
      //u
        jy:=j+len;
        if (x = i) and (y>j) and (y<=jy) then pr(ans);
        inc(ans);
        j:=jy;
    end
    else begin
      //l
        ix:=i-len;
        jy:=j;
        if (y=j) and (x >= ix) and (x < i) then pr(ans);
        inc(ans);
        i:=ix;
      //u
        jy:=j-len;
        if (x = i) and (y >= jy) and (y<=j) then pr(ans);
        inc(ans);
        j:=jy;
    end;
  end;
end.

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

const
  dx : array[0..3] of integer = (1, 0, -1, 0);
  dy : array[0..3] of integer = (0, 1, 0, -1);

var
  x, y, x1, y1, size, ch, dxx, dyy : integer;
  a : array[-100..100, -100..100] of integer;

begin
//  reset(input, 'input.txt');
//  rewrite(output, 'output.txt');

  readln(x1, y1);

  ch := 0;
  x := 0;
  y := 0;
  a[x][y] := 1;
  if (x <> x1) or (y <> y1) then begin
    x := x + 1;
    ch := 0;
    while true do begin
      dxx := dx[ch mod 4];
      dyy := dy[ch mod 4];
      while a[x + dx[(ch + 1) mod 4]][y + dy[(ch + 1) mod 4]] = 1 do begin
        if (x = x1) and (y = y1) then begin
          writeln(ch);
          halt;
        end;
        a[x][y] := 1;
        x := x + dx[ch mod 4];
        y := y + dy[ch mod 4];
      end;
      if (x = x1) and (y = y1) then begin
        writeln(ch);
        halt;
      end;
      inc(ch);
    end;
  end;

  writeln(ch);

end.

var x,y:longint;
begin
read (x,y);
if (y=0) and (x=0) then write ('0');
if (y>x) and (-x<=y) then write (4*y-2);
if (y>=x) and (-x>y) then write (-4*x-1);
if (y<x) and (y<=-x+1) then write (-4*y);
if (y<=x) and (y>-x+1) then write (4*x-3)

end.

program problem1;
uses math;

var	xx, yy, x0, y0, x, y, ans, t: longInt;

begin
	readln( xx, yy );

	t := 2;
	x := 0;
	y := 0;
	ans := 0;
	while ( true ) do
	begin
		x0 := x;
		y0 := y;
		if ( (t mod 2) = 0 ) then
		begin
			if ( (t mod 4) = 0 ) then
				dec( x, (t div 2) )
			else
				inc( x, (t div 2) );
		end
		else
		begin
			if ( ((t-1) mod 4) = 0 ) then
				dec( y, (t div 2) )
			else
				inc( y, (t div 2) );
		end;

		if 	( ( x0 = x ) and ( x = xx ) and ( min( y, y0 ) <= yy ) and ( max( y, y0 ) >= yy ) ) or
			( ( y0 = y ) and ( y = yy ) and ( min( x, x0 ) <= xx ) and ( max( x, x0 ) >= xx ) ) then
				break;

		inc( ans );
		inc( t );
	end;

	writeln( ans );
end.

program zd1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
x,y,all,sh1,sh2,dist1,dist2,i,ans:integer;
curx,cury:array[0..10000]of integer;
begin
 readln(x,y);
 dist1 := 1;
 sh1 := 1;
 sh2 := 10;
 all := 1;
 curx[1] := 0;
 cury[1] := 0;
 ans := 100500;
for i := 2 to 500 do
  begin
    if(all=1)then begin
    if(sh1 mod 2 = 1)then curx[i] := curx[i-1] + dist1
     else curx[i] := curx[i-1]-dist1;
     cury[i] := cury[i-1];
     inc(sh1);
     inc(dist1);
     end
    else begin curx[i] := curx[i-1];cury[i] := curx[i];end ;
    all := -all;
  end;
  for i := 2 to 500 do
  if abs(sqrt(sqr(curx[i-1]-x)+sqr(cury[i-1]-y)) + sqrt(sqr(curx[i]-x)+
   sqr(cury[i]-y)) - sqrt(sqr(curx[i]-curx[i-1])+sqr(cury[i]-cury[i-1]))) <0.01 then begin ans := i-2;break;end;
  writeln(ans);
 readln;
 readln
end.

var
 n,m,i,j,x,y,q,w,e,z,c,xx,yy,x1,y1:longint;
procedure pr(x,y:longint);
begin
 if(x=xx)and(y=yy)then begin writeln(e);halt;end;
end;

begin
// assign(input,'input.txt');reset(input);
// assign(output,'output.txt');rewrite(output);
 readln(xx,yy);
 q:=1;
 while true do
 begin
   for i:=x to x+q do pr(i,y);
   inc(x,q);
   inc(e);
   for i:=y to y+q do pr(x,i);
   inc(y,q);
   inc(e);inc(q);
   for i:=x downto x-q do pr(i,y);
   dec(x,q);
   inc(e);
   for i:=y downto y-q do pr(x,i);
   dec(y,q);
   inc(e);inc(q);
 end;
end.

var
   g,i,x,ans,y,xn,yn: longint;
begin
  readln(x,y);
  xn:=0;
  yn:=0;
  i:=0;
  g:=1;
  while (true) do
   begin
    if g=2 then
     begin
      yn:=yn+i;
      if (x=xn) and (yn-i<=y) and (yn>=y) then begin writeln(ans); exit; end;
      inc(ans);
     end;
    if (g=1) then
     begin
      inc(i);
      xn:=xn+i;
      if (y=yn) and (xn-i<=x) and (xn>=x) then begin writeln(ans); exit; end;
      inc(ans);
     end;
    if g=4 then
     begin
      yn:=yn-i;
      if (x=xn) and (yn+i>=y) and (yn<=y) then begin writeln(ans); exit; end;
      inc(ans);
     end;
    if (g=3) then
     begin
      inc(i);
      xn:=xn-i;
      if (y=yn) and (xn+i>=x) and (xn<=x) then begin writeln(ans); exit; end;
      inc(ans);
     end;
    inc(g);
    if g=5 then g:=1;
   end;
end.

var
 a,b:array[1..1000]of longint;
 y,x1,y1,i,j,n,m,k,t,x:longint;
 s:string;
begin
 x1:=1;
 y1:=1;
 readln(x,y);
 if(x=0)and(y=0)or(x=1)and(y=0)then
 begin
  writeln(0);
  halt;
 end;
 k:=1;
 while true do
 begin
  if(x1=x)and(y1=y)then
  begin
   writeln(k);
   halt;
  end;
  inc(k);
  if(x=x1)and(y=y1)then
  begin
   writeln(k);
   halt;
  end;
  if(x1>0)and(y1>0)then
  begin
   for i:=x1 downto -x1 do if(y1=y)and(i=x)then
   begin
    writeln(k);
    halt;
   end;
   x1:=-x1;
   continue;
  end;
  if(x1<0)and(y1>0)then
  begin
   for i:=y1 downto -y1 do if(i=y)and(x1=x)then
   begin
    writeln(k);
    halt;
   end;
   y1:=-y1;
   continue;
  end;
  if(x1<0)and(y1<0)then
  begin
   for i:=x1 to -x1+1 do if(y1=y)and(i=x)then
   begin
    writeln(k);
    halt;
   end;
   x1:=-x1+1;
   continue;
  end;
  if(x1>0)and(y1<0)then
  begin
   for i:=y1 to -y1+1 do if(i=y)and(x1=x)then
   begin
    writeln(k);
    halt;
   end;
   y1:=-y1+1;
  end;
 end;
end.

const
    fi='';
    fa='';
    maxN=100000;
var
    f,g:text;
    ch:char;
    n,i,j,t,x,y:longint;
    ok:boolean;
    a:array[0..maxN] of longint;
    s:array[0..maxN] of longint;

function kq:longint;
begin
    if (x=0) and (y=0) then exit(0);
    if (x=y)and(x>0) then exit((x-1)*4+1);
    if (x=y) and (x<0) then exit(abs(x)*4-1);
    if (x=-y) and (y>0) then exit((abs(x)-1)*4+2);
    if (x+y-1=0) and (x>0) then exit((abs(y))*4);
    if (x+y-1>=0) then
        if (x-y>0) then exit((x-1)*4+1) else exit((y-1)*4+2);
    if x-y>0 then exit(abs(y)*4);
    exit(abs(x)*4-1);
end;

procedure ghi;
var
    dem:longint;
begin
end;

begin
    assign(f,fi);
    reset(f);
    assign(g,fa);
    rewrite(g);
    read(f,x,y);
    writeln(g,kq);
    close(f);
    close(g);
end.

Const
   fin='';
   fon='';
Var x,y: Longint;
Procedure Start;
   Begin
      assign(input,fin);
      reset(input);
      assign(output,fon);
      rewrite(output);
   End;
Procedure Programe;
   Begin
      readln(x,y);
      if (x = 0) and (y = 0) then
      begin
         writeln(0);
         Halt;
      end;
      if (y > x) and (-x <= y) then
      begin
         writeln(y*4-2);
         Halt;
      end;
      if (y >= x) and (-x > y) then
      begin
         writeln(-x*4-1);
         Halt;
      end;
      if (y < x) and (y <= 1-x) then
      begin
         writeln(-y*4);
         Halt;
      end;
      if (y <= x) and (y > 1-x) then
      begin
         writeln(x*4-3);
         Halt;
      end;
   End;
Procedure Finish;
   Begin
      close(input);
      close(output);
   End;
Begin
   Start;
   Programe;
   Finish;
End.

uses math;
var i,j,m,n,k,l,g,h,y,t,x:longint;
    a,b:array[1..1000]of longint;
begin   {
    assign(input,'input1.txt');
    reset(input);
    assign(output,'output1.txt');
    rewrite(output);}
    read(x,y);
    t:=max(abs(x),abs(y));
    if (x=0)and(y=0) then
    begin
        write(0);
        halt;
    end;
    if (x>=0)and(y>0) then
    begin
        if x<y then
        k:=t*4-2
        else
        k:=t*4-3;
    end;
    if (x<0)and(y>=0) then
    begin
        if abs(x)<=y then
        k:=t*4-2
        else
        k:=t*4-1;
    end;
    if (x<=0)and(y<0) then
    begin
        if abs(x)>=abs(y) then
        k:=t*4-1
        else
        k:=t*4;
    end;
    if (x>0)and(y<=0) then
    begin
        if abs(x)<=abs(y)+1 then
        if abs(x)=abs(y)+1 then
        k:=abs(y)*4
        else
        k:=(t)*4
        else
        k:=(t-1)*4+1;
    end;
    write(abs(k));
end.

var x,y,a,b,c,d:shortint; turn:word=0; stt,e:byte;
begin
        read(x,y);
        a:=0; b:=0; c:=1; d:=0; stt:=1; e:=1;
        while (a<>x) or (b<>y) do
        case stt of
        1: begin
                inc(a);
                if a=c then
                if (a=x) and (b=y) then break
                else begin
                        inc(turn); inc(d,e);
                        stt:=2
                end
           end;
        2: begin
                inc(b);
                if b=d then
                if (a=x) and (b=y) then break
                else begin
                        inc(turn); inc(e); dec(c,e);
                        stt:=3
                end
           end;
        3: begin
                dec(a);
                if a=c then
                if (a=x) and (b=y) then break
                else begin
                        inc(turn); dec(d,e);
                        stt:=4
                end
           end;
        4: begin
                dec(b);
                if b=d then
                if (a=x) and (b=y) then break
                else begin
                        inc(turn); inc(e); inc(c,e);
                        stt:=1
                end
           end;
        end;
        write(turn)
end.

uses math;
var x,y,ans,k:longint;
begin
 read(x,y);
 k:=max(abs(x),abs(y));
  if (x=0) and (y=0) then begin write(0); halt; end;
 ans:=(k-1)*4+1;
 if (y=-k) and (x<>-k) then write(ans+3)
 else if (x=k) and (y<>-k+1) then write(ans)
 else if (x=k) then write(ans-1)

 else if (x=-k) and (y=k) then write(ans+1)
 else if (x=-k) then write(ans+2)
 else if (x<k) and (y=k) then write(ans+1)
 else write(ans+3);
end.

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils,
  Math;

const
  dx: array [0..3] of integer = (1, 0, -1, 0);
  dy: array [0..3] of integer = (0, 1, 0, -1);

var
  a: array [1..100000] of integer;
  x, y, n, m, i, j, w, t, d: integer;
  ans: integer;

procedure Panic;
begin
  write(ans);
  halt(0);
end;

begin
{$IFNDEF ONLINE_JUDGE}
  reset(input, 'input.txt');
  rewrite(output, 'output.txt');
{$ENDIF}
  read(n, m);
  w := 1;
  i := 0;
  j := 0;
  t := 0;
  ans := 0;
  while (i <> n) or (j <> m) do
  begin
    inc(w);
    d := w div 2;
    x := x + d * dx[t];
    y := y + d * dy[t];
    while (i <> x) or (j <> y) do
    begin
      i := i + dx[t];
      j := j + dy[t];
      if (i = n) and (j = m) then
        Panic;
    end;
    t := (t + 1) mod 4;
    inc(ans);
  end;
  Panic;
end.

{$APPTYPE CONSOLE}
{$O-}

uses
  SysUtils,
  Math;

var
  x, y, c, k, ans, sh, st: integer;

procedure go(i, j: integer);
begin
  if (i = y) and (j = x) then begin
    write(ans);
    halt(0);
  end;
  if c = sh then begin
    inc(k);
    if st = 3 then
      st := 0
    else
      inc(st);
    c := 0;
    inc(ans);
  end;
  if k = 2 then begin
    inc(sh);
    k := 0;
  end;
  if st = 0 then begin
    inc(c);
    go(i, j + 1);
  end else if st = 1 then begin
    inc(c);
    go(i + 1, j);
  end else if st = 2 then begin
    inc(c);
    go(i, j - 1);
  end else if st = 3 then begin
    inc(c);
    go(i - 1, j);
  end;
end;

begin
  //reset(input, 'input.txt');
  //rewrite(output, 'output.txt');
  read(x, y);
  st := 0;
  sh := 1;
  ans := 0;
  c := 0;
  k := 0;
  go(0, 0);
end.

var  q,ans,x,y:longint;
function max(a,b:Longint):longint;
begin
 if a>b then max:=a else max:=b;
end;
begin
   readln(x,y);
  if (x=0) and (y=0) then writeln(0) else begin
   q:=max(abs(x),abs(y));
   ans:=4*(q-1);
   if (abs(x)=q) and (y>-x+1) and (x>0) then inc(ans,1)
   else if (abs(y)=q) and (x<y) and (y>0) then inc(ans,2)
   else if (abs(x)=q) and (x<0) and (y<-x) then inc(ans,3)
   else if (abs(y)=q) and (y<0) and (x>y) then inc(ans,4);
   writeln(ans);
  end;
end.

var
x,y,i,j,n,m,k,r,t,l,tek,kol,ans,xx,yy,maxl,maxr,maxd,maxu,tekdl,nap:integer;
begin
readln(x,y);
xx:=0;
yy:=0;
m:=1;
nap:=1;
ans:=0;
tekdl:=1;
kol:=0;
if (x=0) and (y=0) then begin writeln(0); exit; end;
while m=1 do begin
for i:=1 to tekdl do begin
inc(xx,nap);
if (yy=y) and (xx=x) then begin writeln(ans);
exit; end;
end;
inc(ans);
for i:=1 to tekdl do begin
inc(yy,nap);
if (xx=x) and (yy=y) then begin writeln(ans);
exit;
end;
end;
inc(ans);
inc(tekdl);
nap:=nap*(-1);
end;
end.

const dx:array[0..3] of integer = (1,0,-1,0);
      dy:array[0..3] of integer = (0,1,0,-1);
var ans,q,w,x,y,i,l,k,j,m,n:longint;
    a:array[-200..200,-200..200] of boolean;
begin
read(q,w);
x:=0;
y:=0;
i:=0;
ans:=0;
while true do
begin
if (x=q) and (y=w) then break;
a[x,y]:=true;
l:=(i+1) mod 4;
if (x=0) and (y=0) then
  begin x:=x+dx[i]; y:=y+dy[i] end else
  begin
   if a[x+dx[l],y+dy[l]]=false then begin i:=l; inc(ans); end;
   x:=x+dx[i];
   y:=y+dy[i];
  end;
end;
writeln(ans);
end.

var x,y,xx,yy,k,q,ans:longint;
 begin
  read (x,y);
  k:=1;
  xx:=0;
  yy:=0;
  q:=0;
  ans:=0;
  while true do
   begin
    if q=0 then begin
                 if (yy=y) and (xx+k>=x) and (xx<=x)
                                          then begin
                                               writeln (ans);
                                               halt(0);
                                              end
                                         else xx:=xx+k;
                end
           else begin
                 if (yy=y) and (xx-k<=x) and (xx>=x)
                                         then begin
                                               writeln (ans);
                                               halt(0);
                                              end
                                         else xx:=xx-k;
                end;
    inc (ans);
    if q=0 then begin
                 if (xx=x) and (yy+k>=y) and (yy<=y)
                                         then begin
                                               writeln (ans);
                                               halt(0);
                                              end
                                         else yy:=yy+k;
                end
           else begin
                 if (xx=x) and (yy-k<=y) and (yy>=y)
                                         then begin
                                               writeln (ans);
                                               halt(0);
                                              end
                                         else yy:=yy-k;
                end;
    inc (ans);
    q:=1-q;
    inc (k);
   end;
 end.

program ex;
var
x,y:integer;
i,j,kx,ky,m:longint;
a,b:integer;
flag:booleaN;
begin
readln(kx,ky);
m:=0;
x:=0;
y:=0;
a:=0;
b:=0;
flag:=true;
while (x<>kx)or(y<>ky) do begin
if flag then begin
if a>=0 then inc(a);
if a>0 then for i:=1 to a do begin inc(x); if (x=kx)and(y=ky) then begin write(m);exit;end;end;
if a<0 then dec(a);
if a<0 then for i:=-1 downto a do begin dec(x); if (x=kx)and(y=ky) then begin write(m);exit;end; end;
a:=-a;end
else begin if b>=0 then inc(b);
if b>0 then for i:=1 to b do begin inc(y); if (x=kx)and(y=ky) then begin write(m);exit;end; end;
if b<0 then dec(b);
if b<0 then for i:=-1 downto b do begin dec(y); if (x=kx)and(y=ky) then begin write(m);exit;end; end;
b:=-b; end;
inc(m);

flag:=not flag;
end;
write(m);
end.

program E1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  x, y, n : integer;

procedure I(x, y : integer; var n : integer);
  begin
    if (abs(x) >= abs(y)) then n := 1 + 4 * (abs(x) - 1)
      else n := 2 + 4 * (abs(y) - 1);
  end;

procedure II(x, y : integer; var n : integer);
  begin
    if (abs(y) >= abs(x)) then n := 2 + 4 * (abs(y) - 1)
      else n := 3 + 4 * (abs(x) - 1);
  end;

procedure III(x, y : integer; var n : integer);
  begin
    if (abs(x) >= abs(y)) then n := 3 + 4 * (abs(x) - 1)
      else n := 4 + 4 * (abs(y) - 1);
  end;

procedure IV(x, y : integer; var n : integer);
  begin
    if (abs(y) + 1 >= abs(x)) then n := 4 + 4 * (abs(y) - 1)
      else n := 1 + 4 * (abs(x) - 1);
  end;

begin
  readln(x, y);
  n := 0;
  if (x = 0) and (y = 0)  then n := 0
    else if (x = 1) and (y = 0) then n := 0
      else if (x >= 0) and (y >= 0) then I(x, y, n)
        else if (x <= 0) and (y >= 0) then II(x, y, n)
          else if (x <= 0) and (y <= 0) then III(x, y, n)
            else if (x >= 0) and (y <= 0) then IV(x, y, n);
  writeln(n);
  readln;
end.

var
  a, b, c, d, ans, k, f, i: int64;

begin
  ans := 0;
  readln(a, b);
  c := 0;
  d := 0;
  if (a = c) and (d = b) then begin
    writeln(0);
    halt();
  end;
  f := 1;
  k := 1;
  while true do
  begin
    if f mod 2 = 1 then begin
      i := 1;
      while i <= k do
      begin
        inc(c);
        if (c = a) and (d = b) then begin
          writeln(ans);
          halt();
        end;
        inc(i);
      end
    end
    else begin
      i := 1;
      while i <= k do
      begin
        dec(c);
        if (c = a) and (d = b) then begin
          writeln(ans);
          halt();
        end;
        inc(i);
      end;
    end;
    if (c = a) and (d = b) then begin
      writeln(ans);
      halt();
    end;
    inc(ans);
    if f mod 2 = 1 then begin
      i := 1;
      while i <= k do
      begin
        inc(d);
        if (c = a) and (d = b) then begin
          writeln(ans);
          halt();
        end;
        inc(i);
      end
    end
    else begin
      i := 1;
      while i <= k do
      begin
        dec(d);
        if (c = a) and (d = b) then begin
          writeln(ans);
          halt();
        end;
        inc(i);
      end;
    end;
    if (c = a) and (d = b) then begin
      writeln(ans);
      halt();
    end;
    inc(ans);
    inc(k);
    inc(f);
  end;
end.

{$APPTYPE CONSOLE} program Project1; uses SysUtils; var n,x,y: integer; begin if (ParamCount>0) and (ParamStr(1)='DEBUG') then begin AssignFile(Input, 'input.txt'); Reset(Input); AssignFile(Output, 'output.txt'); ReWrite(Output); end; Read(x); read (y); if ((x>0) and (y>-x+1) and (y<=x)) then n:= 4*x -3; if ((y>0) and (y>x) and (y>=-x)) then n:= 4*y-2; if ((x<0) and (y>=x) and (y<-x)) then n:= -x*4-1; if ((y<0) and(y<x) and (y<=-x+1)) then n:=-y*4; WriteLn(n); end.

var
  x,y,xc,yc,i,t,j:longint;

begin
  readln(x,y);
  xc:=0;
  yc:=0;
  t:=0;
  i:=1;
  while true do
  begin
    if (xc=x) and (yc=y) then
    begin
      writeln(t);
      halt(0);
    end;
    for j:=1 to i do
    begin
      inc(xc);
      if (xc=x) and (yc=y) then
      begin
        writeln(t);
        halt(0);
      end;
    end;
    inc(t);
    for j:=1 to i do
    begin
      inc(yc);
      if (xc=x) and (yc=y) then
      begin
        writeln(t);
        halt(0);
      end;
    end;
    inc(t);
    inc(i);
   for j:=1 to i do
    begin
      dec(xc);
      if (xc=x) and (yc=y) then
      begin
        writeln(t);
        halt(0);
      end;
    end;
    inc(t);
    for j:=1 to i do
    begin
      dec(yc);
      if (xc=x) and (yc=y) then
      begin
        writeln(t);
        halt(0);
      end;
    end;
    inc(t);
    inc(i);
  end;
end.

var
ans,x,y,a,b,i:longint;
bol,l,u,r,d:boolean;
begin
readln(x,y);
l:=false;
u:=false;
r:=true;
d:=false;
a:=0;
b:=0;
if (x=a) and (y=b) then writeln(0)
else begin
while true do begin
if (bol)or((x=a)and(y=b)) then begin
 writeln(ans-1);
break;
end
else begin
      if r then begin
          r:=false;
          u:=true;
          inc(ans);
          for i:=a to abs(a)+1do  if (i=x) and (b=y) then begin
              bol:=true;
              break;
          end;
          a:=i;
      end
      else
      if u then begin
          u:=false;
          l:=true;
          inc(ans);
          for i:=b to abs(b)+1 do if (a=x)and(i=y) then begin
              bol:=true;
              break;
          end;
          b:=i;
      end
      else
      if l then begin
          l:=false;
          d:=true;
          inc(ans);
          for i:=a downto -a do if (i=x)and(b=y) then begin
              bol:=true;
              break;
          end;
          a:=i;
      end
      else
      if d then begin
          d:=false;
          r:=true;
          inc(ans);
          for i:=b downto -b do if (x=a)and(i=y) then begin
              bol:=true;
              break;
          end;
          b:=i;
      end;
      end;
end;
end;
end.

var x,y,i,j,p,h,k:longint;
begin
   readln(x,y);
   i:=0;
   j:=0;
   h:=1;
   k:=0;
   p:=0;
   while (i<>x)or(j<>y) do
      begin
         if ((k=0)and(h>1))or(k=h)
         then inc(p);
         if k<h
         then if h mod 2=0
              then dec(i)
              else inc(i)
         else if h mod 2=0
              then dec(j)
              else inc(j);
         inc(k);
         if k=2*h
         then begin
                 inc(h);
                 k:=0;
              end;
      end;
   writeln(p);
end.

Uses Math,SysUtils;
Const dx:array[0..3] of Integer=(1,0,-1,0);
      dy:array[0..3] of Integer=(0,1,0,-1);
Var X,Y,Xt,Yt,Xk,Yk,K,I,J:Integer;
Begin
    ///reset(input,'input.txt');
    ///assign(output,'output.txt');
    readln(X,Y);
    J:=0;
    K:=0;
    Xt:=0;
    Yt:=0;
    Xk:=1;
    Yk:=0;
    I:=1;
    While (Xt<>X) or (Yt<>Y) do
    begin
        Xk:=Xt+dx[J]*I;
        Yk:=Yt+dy[J]*I;
        Repeat
           Inc(Xt,dx[J]);
           Inc (Yt,dy[J]);
        Until ((Xt=Xk) and (Yt=Yk)) or ((Xt=X) and (Yt=Y));
        If (Xt=X) and (Yt=Y)
        then begin
                write(K);
                Halt(0);
             end;
        J:=(J+1) mod 4;
        If J mod 2=0
        then Inc(I);
        Inc(K);
    end;
    write(K);
End.

uses math;
var n,m,j,i,k,l,ans,x,y,e,x1,y1,dx,dy,z:longint;
a:array[0..220000]of longint;
begin
{assign(input,'input.txt');reset(input);
assign(output,'output.txt');rewrite(output);}
readln(x,y);
if (x=y)and(x=0) then begin writeln(0);halt;end;
if (x=1)and(y=0) then begin writeln(0);halt;end;
if (x=1)and(y=1) then begin writeln(1);halt;end;
if (x=0)and(y=1) then begin writeln(2);halt;end;
k:=1;
x1:=1;
y1:=1;
dx:=2;
dy:=2;
z:=1;
while 1>0 do
 begin
  if z=1 then
        begin
                 if(x=x1)and(y=y1) then begin writeln(k);halt;end;
         x1:=x1-dx;inc(z);

         inc(k);
         if (y1=y)and(x>=x1)and(x<x1+dx) then
                begin
                 writeln(k);
                 halt;
                end;
         dx:=dx+1;
        end else
  if z=2 then
        begin
         if(x=x1)and(y=y1) then begin writeln(k);halt;end;
         y1:=y1-dy;inc(z);
         inc(k);
         if (x1=x)and(y>=y1)and(y<y1+dy) then
                begin
                 writeln(k);
                 halt;
                end;
         dy:=dy+1;
        end else
  if z=3 then
        begin
                 if(x=x1)and(y=y1) then begin writeln(k);halt;end;
         x1:=x1+dx;inc(z);
         inc(k);
        if (y1=y)and(x<=x1)and(x>x1-dx) then
                begin
                 writeln(k);
                 halt;
                end;
         dx:=dx+1;
        end else
  if z=4 then begin
                       if(x=x1)and(y=y1) then begin writeln(k);halt;end;
              y1:=y1+dy;
               inc(k);

              if (x1=x)and(y<=y1)and(y>y1-dy) then
                begin
                 writeln(k);
                 halt;
                end;
              dy:=dy+1;z:=1;
              end;

 end;

end.

var
   g,i,x,ans,y,xn,yn: longint;
begin
  readln(x,y);
  xn:=0;
  yn:=0;
  i:=0;
  g:=1;
  while (true) do
   begin
    if g=2 then
     begin
      yn:=yn+i;
      if (x=xn) and (yn-i<=y) and (yn>=y) then begin writeln(ans); exit; end;
      inc(ans);
     end;
    if (g=1) then
     begin
      inc(i);
      xn:=xn+i;
      if (y=yn) and (xn-i<=x) and (xn>=x) then begin writeln(ans); exit; end;
      inc(ans);
     end;
    if g=4 then
     begin
      yn:=yn-i;
      if (x=xn) and (yn+i>=y) and (yn<=y) then begin writeln(ans); exit; end;
      inc(ans);
     end;
    if (g=3) then
     begin
      inc(i);
      xn:=xn-i;
      if (y=yn) and (xn+i>=x) and (xn<=x) then begin writeln(ans); exit; end;
      inc(ans);
     end;
    inc(g);
    if g=5 then g:=1;
   end;
end.

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
x, y, N:integer;
begin
read(x); readln(y);
if (y>0)and(y>=abs(x))and(y<>x) then N:=2+(y-1)*4  else
if (x<0) and (abs(x)>=abs(y)) and (abs(x)<>y) then N:=3+(abs(x)-1)*4  else
if (x>0) and (((y<0)and((x-1)>abs(y))) or (y>=0)) then N:=1+(x-1)*4 else
N:=abs(y)*4;
if ((x=0)and(y=0))or((x=1)and(y=0)) then N:=0;
write (N);
readln;
end.

{$APPTYPE CONSOLE}
program Project1;

uses
  SysUtils;

var
  n,x,y: integer;

begin
  if (ParamCount>0) and (ParamStr(1)='DEBUG') then begin
    AssignFile(Input, 'input.txt');
    Reset(Input);
    AssignFile(Output, 'output.txt');
    ReWrite(Output);
  end;

  Read(x);
  read (y);
  if ((x>0) and (y>-x+1) and (y<=x)) then
    n:= 4*x -3;
  if ((y>0) and (y>x) and (y>=-x)) then
    n:= 4*y-2;
  if ((x<0) and (y>=x) and (y<-x)) then
    n:= -x*4-1;
  if ((y<0) and(y<x) and (y<=-x+1)) then
    n:=-y*4;
  WriteLn(n);
end.

Var x,y:longint;
    begin
      read(x,y);
      if (x>=0) and (y>=0) then begin
                                  if (x<=1) and (y=0) then begin writeln(0); halt; end;
                                  if x>=y then writeln((x-1)*4+1)
                                          else writeln((y-1)*4+2);
                                end
       else if (x<=0) and (y>=0) then begin
                                        if abs(x)<=y then writeln((y-1)*4+2)
                                                     else writeln((abs(x)-1)*4+3);
                                      end
       else if (x<=0) and (y<=0) then begin
                                       if abs(x)>=abs(y) then writeln((abs(x)-1)*4+3)
                                                         else writeln((abs(y))*4);
                                     end
       else if (x>=0) and (y<=0) then begin
                                        if x-1<=abs(y) then writeln(abs(y)*4)
                                                     else writeln((abs(x)-1)*4+1);
                                      end;
    end.

program ProjectA;

{$APPTYPE CONSOLE}
{$R+,O-}

uses
  SysUtils,
  Math;

label
  link;

var
  x, y, m1, m2: integer;

begin
  {$IFNDEF ONLINE_JUDGE}
  Reset(input, 'input.txt');
  Rewrite(output, 'output.txt');
  {$ENDIF}

  read(x, y);
  if (x = 0) and (y = 0) then
    begin
      write(0);
      exit;
    end;

  if (y > x) and (y >= -x) then   //1
    begin
      write(4 * abs(y) - 2);
      exit;
    end;

  if (y <= x) and (y > -x + 1) then     //2
    begin
      write(4 * abs(x) - 3);
      exit;
    end;

  if (y < x) and (y <= -x + 1) then        //3
    begin
      write(4 * abs(y));
      exit;
    end;

  if (y >= x) and (y < -x) then           //4
    begin
      write(4 * abs(x) - 1);
      exit;
    end;

end.

var x,y:integer;
begin
  read(x,y);
  if(y=0)and(x=0)then write('0');
  if(y>x)and(-x<=y)then write(4*y-2);
  if(y>=x)and(-x>y)then write(-4*x-1);
  if(y<x)and(y<=-x+1)then write(-4*y);
  if(y<=x)and(y>-x+1)then write(4*x-3)
end.

var
 x,y,a,b,n,i,z,shag,j,mx,my,cas,s:integer;
 t:text;
procedure povorot();
begin
  cas:=(cas+1) mod 4;
  case cas of
  0: begin; mx:=1; my:=0; end;
  1: begin; mx:=0; my:=1; end;
  2: begin; mx:=-1; my:=0; end;
  3: begin; mx:=0; my:=-1; end;
  end;
  inc(n);
end;

begin
    shag:=1;
    mx:=1;
    read(x,y);
//    writeln('0)0 0|0');
    while not(a=x) or not(b=y) do begin
      for j:=1 to shag do begin
        a:=a+mx;
        b:=b+my;
        inc(s);
        if (a=x) and (b=y) then break;
//        writeln(s,')',a,' ',b,'|',n);
      end;
      inc(z);
      if (z=2) then begin
        z:=0;
        inc(shag);
      end;
      if not(a=x) or not(b=y) then povorot();
   end;
   writeln(n);
end.

var
xx,yy,i,j:longint;
x,y:array [0..10000] of longint;
function max(a,b:longint):longint;
  begin
    if a>b then exit(a);
    exit(b);
  end;
procedure swap(var a,b:longint);
var k:longint;
  begin
    k:=a;
    a:=b;
    b:=k;
  end;
function pren(x1,y1,x2,y2:longint):boolean;
  begin
    if x1>x2 then swap(x1,x2);
    if y1>y2 then swap(y1,y2);
    if ( xx>=x1 ) and (xx <= x2) and (yy>=y1) and (yy<=y2) then exit(true);
    exit(false);
  end;
begin
  read(xx,yy);
  x[1]:=0; y[1]:=0;
  for i:=2 to 1000 do
    begin
      if i=2 then
        begin
          x[2]:=1;
          y[2]:=0;
        end
      else
         if i mod 4=3 then
                begin
                  x[i]:=i div 4+1;
                  y[i]:=x[i];
                end
                  else
                    if i mod 4=1 then
                      begin
                        x[i]:=-x[i-2];
                        y[i]:=-y[i-2];
                      end
                        else
                          if i mod 4=2 then
                            begin
                              y[i]:=-i div 4;
                              x[i]:=abs(y[i])+1;
                            end
                             else begin
                              x[i]:=-i div 4;
                              y[i]:=i div 4;
                             end;
      if pren(x[i-1],y[i-1],x[i],y[i]) then
        begin
          writeln(i-2);
          halt;
        end;
    end;
end.

{$R-,S-,Q-,I-,O+}
{$M 32000000}

{$APPTYPE CONSOLE}

uses Math;
const
inf = round(1e9);
maxn = round(1e5) + 200;
md = round(1e9) + 7;
dx : array [1..4] of longint = (1,0,-1,0);
dy : array [1..4] of longint = (0,1,0,-1);
var
x,y,curx,cury,i,k,dir,ans,same : longint;

procedure check();
begin
 if (curx = x) and (cury = y) then
 begin
  writeln(ans);
  halt;
 end;
end;

begin
 //reset (input,'input.txt');
 //rewrite (output,'output.txt');
 randomize;
 readln(x,y);
 curx:=0;
 cury:=0;
 check();
 k:=1;
 ans:=0;
 dir:=1;
 same:=0;
 while true do
 begin
  inc(same);
  for i:=1 to k do
  begin
   curx:=curx + dx[dir];
   cury:=cury + dy[dir];
   check();
  end;
  dir:=dir mod 4 + 1;
  inc(ans);
  if same = 2 then
  begin
   same:=0;
   inc(k);
  end;
 end;
end.

Var fx,fy,x,y,dx,dy,i,j,ans,k:LongInt;

Procedure Change (Var dx,dy:LongInt);
Begin
     If (dx=1) and (dy=0)
     then Begin dx:=0; dy:=1 End
     else If (dx=0) and (dy=1)
          then Begin dx:=-1; dy:=0 End
          else If (dx=-1) and (dy=0)
               then Begin dx:=0; dy:=-1 End
               else Begin dx:=1; dy:=0; ENd;
End;

Begin
     //ReSet (input,'input.txt');
     //ReWrite (output,'output.txt');
     Readln (fx,fy);
     x:=0;y:=0;
     dx:=1;dy:=0;
     k:=1;
     ans:=0;
     If (x=fx) and (y=fy)
          then Begin Writeln (ans); Halt (0); ENd;

     For I:=1 to 1000000 do
     Begin
          For J:=1 to k do
          Begin
          x:=x+dx;y:=y+dy;
          If (x=fx) and (y=fy)
          then Begin Writeln (ans); Halt (0); ENd;
          ENd;
          Inc (ans);

          Change (dx,dy);
          For J:=1 to k do
          Begin
          x:=x+dx;y:=y+dy;
          If (x=fx) and (y=fy)
          then Begin Writeln (ans); Halt (0); ENd;
          ENd;
          Inc (ans);
          Change (dx,dy);
Inc (k);

     End;
End.

program CF1_1;
var otv:longint;
    x,y,x1,y1,nh,h:longint;
    pos:byte;
begin
readln(x,y);

nh:=1;
pos:=1;

while (X1<>x) or (y1<>y) do
begin

case pos of
1:begin inc(x1) end;
2:begin inc(y1) end;
3:begin dec(x1) end;
4:begin dec(y1) end;
end;
inc(h);
If (h<>nh) or ((x1=x)and(y1=y)) then continue;
h:=0;
If(pos=2) or (pos=4) then inc(nh);
inc(pos);
if (pos=5)  then pos:=1;
inc(otv);
end;

writeln(otv);

end.

uses math;
var x,y,xx,xxx,yyy,yy,o,r,q:longint;
begin
  read(x,y);
  if (x=0)and(y=0) then
    begin
      writeln(0);
      exit;
    end;
  if (x=1)and(y=0) then
    begin
      writeln(0);
      exit;
    end;
  if (x=1)and(y=1) then
    begin
      writeln(1);
      exit;
    end;
  xx:=1;
  yy:=1;
  o:=2;
  r:=2;
  q:=1;
  while (xx<>x)or(yy<>y) do
    begin
      xxx:=xx;
      yyy:=yy;
      if r=1 then yy:=yy+o
      else if r=2 then xx:=xx-o
      else if r=3 then yy:=yy-o
      else xx:=xx+o;
      inc(r);
      if r mod 2=0 then o:=o+1;
      if r=4 then
        begin
          r:=0;
        end;
      inc(q);
      if (xxx=x)and(xx=x)and(min(yy,yyy)<=y)and(max(yy,yyy)>=y) then break;
      if (yyy=y)and(yy=y)and(min(xx,xxx)<=x)and(max(xx,xxx)>=x) then break;
    end;
  writeln(q);
end.

program TA;

{$APPTYPE CONSOLE}

uses
  Math;

var
  x, y, step, side, ans, curx, cury, j: integer;

begin
  {$IFNDEF ONLINE_JUDGE}
  reset(input, 'TA.in');
  rewrite(output, 'TA.out');
  {$ENDIF}
  readln(x, y);
  step := 1;
  side := 1;
  ans := 0;
  curx := 0;
  cury := 0;
  while not ((curx = x) and (cury = y)) do begin
    if side = 1 then begin
      for j := 1 to step do begin
        inc(curx);
        if (curx = x) and (cury = y) then begin
          write(ans);
          halt(0);
        end;
      end;
      side := 2;
      inc(ans);
      continue;
    end;
    if side = 2 then begin
      for j := 1 to step do begin
        inc(cury);
        if (curx = x) and (cury = y) then begin
          write(ans);
          halt(0);
        end;
      end;
      side := 3;
      inc(ans);
      step := step + 1;
      continue;
    end;
    if side = 3 then begin
      for j := 1 to step do begin
        dec(curx);
        if (curx = x) and (cury = y) then begin
          write(ans);
          halt(0);
        end;
      end;
      side := 4;
      inc(ans);
      continue;
    end;
    if side = 4 then begin
      for j := 1 to step do begin
        dec(cury);
        if (curx = x) and (cury = y) then begin
          write(ans);
          halt(0);
        end;
      end;
      side := 1;
      inc(ans);
      step := step + 1;
      continue;
    end;
  end;
  write(ans);
end.

{$APPTYPE CONSOLE}

uses
  SysUtils,math;
var t ,ans ,a,b,x,y,qx,qy : integer;

begin
 readln(a,b);
 x := 0;
 y := 0;
 ans := 0;
 t := max(abs(a),abs(b));
 if t >= 1 then
 begin
 if (t >= 1) then
 begin
  ans := ans + 4*(t-1);
  y := -t + 1;
  x := t -1;
 end;
 if (b = y) and (a = x + 1) then writeln(ans) else
 if (b > y) and (a > x) then
  writeln(ans + 1)
 else
  if (b = -y + 1) and (a <=x) then
   writeln(ans + 2)
  else
  if (a < -x) and (b < -y+ 1) then
   writeln(ans + 3)
  else
   writeln(ans + 4);
 halt;
 end;
 if t = 0 then
 begin
  writeln(0);
  halt;
 end;
end.

{$APPTYPE CONSOLE}
{$R+}
uses SysUtils, Math;

var
  x, y, i, j, n, k, l, q, w: integer;

begin

  read(x, y);
  i := 0;
  j := 0;
  k := 1;
  l := 0;
  if (i = x) and (j = y) then
    begin
      write(l);
      Exit;
    end;
  while (i <> x) or (y <> j) do
  begin
  if (i = x) and (j = y) then
    begin
      write(l);
      Exit;
    end;
    q := i;
    while ((i <> x) or (y <> j)) and (Abs(i - q) <> k) do
      inc(i);

    if (i = x) and (j = y) then
    begin
      write(l);
      Exit;
    end;
    inc(l);
    w := j;
    while ((i <> x) or (y <> j)) and (Abs(j - w) <> k) do
      inc(j);

    if (i = x) and (j = y) then
    begin
      write(l);
      Exit;
    end;
    inc(l);
    inc(k);

    q := i;
    while ((i <> x) or (y <> j)) and (Abs(i - q) <> k) do
      dec(i);

    if (i = x) and (j = y) then
    begin
      write(l);
      Exit;
    end;
    inc(l);

    w := j;
    while ((i <> x) or (y <> j)) and (Abs(j - w) <> k) do
      dec(j);

    if (i = x) and (j = y) then
    begin
      write(l);
      Exit;
    end;
    inc(l);
    inc(k);
  end;

end.

var x,y,a,b,c,d:shortint; turn:word=0; stt,e:byte;
begin
        read(x,y);
        a:=0; b:=0; c:=1; d:=0; stt:=1; e:=1;
        while (a<>x) or (b<>y) do
        case stt of
        1: begin
                inc(a);
                if a=c then
                if (a=x) and (b=y) then break
                else begin
                        inc(turn); inc(d,e);
                        stt:=2
                end
           end;
        2: begin
                inc(b);
                if b=d then
                if (a=x) and (b=y) then break
                else begin
                        inc(turn); inc(e); dec(c,e);
                        stt:=3
                end
           end;
        3: begin
                dec(a);
                if a=c then
                if (a=x) and (b=y) then break
                else begin
                        inc(turn); dec(d,e);
                        stt:=4
                end
           end;
        4: begin
                dec(b);
                if b=d then
                if (a=x) and (b=y) then break
                else begin
                        inc(turn); inc(e); inc(c,e);
                        stt:=1
                end
           end;
        end;
        write(turn)
end.

const mas:array[1..2,1..4] of longint = ((+1,0,-1,0),(0,+1,0,-1));
var
    used:array[-100..100,-100..100] of boolean; answer,dir,i,j,x,y:longint;

begin

  readln(x,y); if (x=0) and (y=0) then begin writeln(0); halt; end;
  answer:=0; i:=0; j:=0; dir:=1; used[0,0]:=true;
  while true do
    begin
      i:=i+mas[1,dir]; j:=j+mas[2,dir]; used[i,j]:=true;
      if (x=i) and (y=j) then begin writeln(answer); halt; end;
      if (dir=1) and (used[i+mas[1,2],j+mas[2,2]]=false) then begin inc(answer); dir:=2; end else
      if (dir=2) and (used[i+mas[1,3],j+mas[2,3]]=false) then begin inc(answer); dir:=3; end else
      if (dir=3) and (used[i+mas[1,4],j+mas[2,4]]=false) then begin inc(answer); dir:=4; end else
      if (dir=4) and (used[i+mas[1,1],j+mas[2,1]]=false) then begin inc(answer); dir:=1; end;
    end;

end.

var x,y,i,n,j,sum,poz:integer;
    s,s1,s2:string;
    a:array [1..100] of string;
begin
 read(x);
 readln(y);
 if ((y=0) and (x=0)) or ((y=0) and (x=1)) then
  begin
   writeln(0);
   readln;
   readln;
   exit;
  end;
if (y>x) and (y>=-x) then
 writeln((y-1)*4+2);
if (y<-x) and (y>=x) then
 writeln((abs(x)-1)*4+3);
if (y<x) and (y<=-x+1) then
 writeln(abs(y)*4);
if (y>-x+1) and (y<=x) then
 writeln((x-1)*4+1);
 readln;
 readln;
end.

uses math;
type mass=array[1..100] of integer;
var u:boolean;
    m:mass;
    ch:char; s,ss:string;
    min1,max1,j,x,x1,y1,y,a,b,k,c,i,z,q,n,num:integer;
Begin
//   assign(input,'input.txt');
//   assign(output,'output.txt');
   readln(x,y);
   if (x=0) and (y=0)
   then Begin
          writeln(0);
          halt(0);
        end;
   a:=0;
   b:=1;
   n:=1;
   x1:=0;
   y1:=0;
   for i:=1 to 100000 do
      Begin
         case n of
         1:Begin
              if y1=y
              then if (x1+b>=x) and (x1<=x)
                   then Begin
                           writeln(a);
                           halt(0);
                        end;
              inc(x1,b);
              inc(n);
              inc(a);
           end;
         2:Begin
              if x1=x
              then if (y1+b>=y) and (y1<=b)
                   then Begin
                           writeln(a);
                           halt(0);
                        end;
              inc(y1,b);
              inc(n);
              inc(a);
              inc(b);
           end;
         3:Begin
              if y1=y
              then if (x1-b<=x) and (x1>=x)
                   then Begin
                           writeln(a);
                           halt(0);
                        end;
              dec(x1,b);
              inc(n);
              inc(a);
           end;
         4:Begin
              if x1=x
              then if (y1-b<=y) and (y1>=y)
                   then Begin
                          writeln(a);
                          halt(0);
                        end;
              dec(y1,b);
              n:=1;
              inc(a);
              inc(b);
           end;
         end;
      end;
end.

uses math;
type mass=array[1..100] of integer;
var u:boolean;
    m:mass;
    ch:char; s,ss:string;
    min1,max1,j,x,x1,y1,y,a,b,k,c,i,z,q,n,num:integer;
Begin
//   assign(input,'input.txt');
//   assign(output,'output.txt');
   readln(x,y);
   if (x=0) and (y=0)
   then Begin
          writeln(0);
          halt(0);
        end;
   a:=0;
   b:=1;
   n:=1;
   x1:=0;
   y1:=0;
   while 1=1 do
      Begin
         case n of
         1:Begin
              if y1=y
              then if (x1+b>=x) and (x1<=x)
                   then Begin
                           writeln(a);
                           halt(0);
                        end;
              inc(x1,b);
              inc(n);
              inc(a);
           end;
         2:Begin
              if x1=x
              then if (y1+b>=y) and (y1<=b)
                   then Begin
                           writeln(a);
                           halt(0);
                        end;
              inc(y1,b);
              inc(n);
              inc(a);
              inc(b);
           end;
         3:Begin
              if y1=y
              then if (x1-b<=x) and (x1>=x)
                   then Begin
                           writeln(a);
                           halt(0);
                        end;
              dec(x1,b);
              inc(n);
              inc(a);
           end;
         4:Begin
              if x1=x
              then if (y1-b<=y) and (y1>=y)
                   then Begin
                          writeln(a);
                          halt(0);
                        end;
              dec(y1,b);
              n:=1;
              inc(a);
              inc(b);
           end;
         end;
      end;
end.

{$APPTYPE CONSOLE}
program Project1;

uses
  SysUtils;

var
  n,x,y: integer;

begin
  if (ParamCount>0) and (ParamStr(1)='DEBUG') then begin
    AssignFile(Input, 'input.txt');
    Reset(Input);
    AssignFile(Output, 'output.txt');
    ReWrite(Output);
  end;

  Read(x);
  read (y);
  if ((x>0) and (y>-x+1) and (y<=x)) then
    n:= 4*x -3;
  if ((y>0) and (y>x) and (y>=-x)) then
    n:= 4*y-2;
  if ((x<0) and (y>=x) and (y<-x+1)) then
    n:= -x*4-1;
  if ((y<0) and(y<x) and (y<=-x+1)) then
    n:=-y*4;
  WriteLn(n);
end.

{$APPTYPE CONSOLE}

uses SysUtils, Math;

type int = integer;

var x, y, r: int;

begin
  //reset(input, 'input.txt'); rewrite(output, 'output.txt');

  r:= 0;
  read(x, y);
  r:= 4*(max(abs(x), abs(y))-1);
  if (x > 0) and (y >= 0) then
    if 4*x <= r then
      inc(r, 2)
    else
      inc(r, 1)
  else if (x <= 0) and (y > 0) then
    if 4*y <= r then
      inc(r, 3)
    else
      inc(r, 2)
  else if (x < 0) and (y <= 0) then
    if -4*x <= r then
      inc(r, 4)
    else
      inc(r, 3)
  else if -4*y <= r then
    inc(r, 5)
  else
    inc(r, 4);
  if ((x = 0) and (y = 0)) or ((x = 1) and (y = 0)) then
    write(0)
  else
    write(r)
end.

program ll;
 const dd=1000000007;
 var x,y,b,c,n,m,j,t,t2,k,i:longint;{F:BOOLEAN;{z,x,y:array[-1..255]of int64;
 u:array[0..22501]of longint;r1,r2:real;x:array[0..100003]of longint;{real;
 y:array[0..500]of int64;}

 begin
{assign(input,'input.txt');reset(input);
sassign(output,'output.txt');rewrite(output);}
read(x,y);
if (y=0) and (x=0) then begin write(0);halt; end;
if (y>x+1) and (y<=x) then begin write(x*4-3);halt; end;
if (y>x) and (y>=-x) then begin write(y*4-2);halt; end;
if (y<-x) and (y>=x) then begin write(-x*4-1);halt; end;
 write(-y*4);halt;
 end.

program ll;
 const dd=1000000007;
 var x,y,b,c,n,m,j,t,t2,k,i:longint;{F:BOOLEAN;{z,x,y:array[-1..255]of int64;
 u:array[0..22501]of longint;r1,r2:real;x:array[0..100003]of longint;{real;
 y:array[0..500]of int64;}

 begin
{assign(input,'input.txt');reset(input);
sassign(output,'output.txt');rewrite(output);}
read(x,y);
if (y=0) and (x=0) then begin write(0);halt; end;
if (y>-x-1) and (y<=x) then begin write(x*4-3);halt; end;
if (y>x) and (y>=-x) then begin write(y*4-2);halt; end;
if (y<-x) and (y>=x) then begin write(-x*4-1);halt; end;
 write(-y*4);halt;
 end.

{$R+ Q+ I+}
{$apptype console}
uses
    sysutils,math;
var
   x,y,l,r,i,k : integer;
begin
    read(x,y);
    if (x = 0) and (y = 0) then begin
        write(0);
        halt;
    end;
    l := 0;
    r := 0;
    i := 1;
    k := 0;
    while (l <> x) or (r <> x) do begin
           l := l + i;
           inc(k);
           if (l = x) and (r = y) then begin
               write(k-1);
               halt;
           end;
           r := r + i;
           inc(k);
           if (l = x) and (r = y) then begin
               write(k-1);
               halt;
           end;
           inc(i);
           dec(l,i);
           inc(k);
           if (l = x) and (r = y) then begin
               write(k-1);
               halt;
           end;
           dec(r,i);
           inc(i);
           inc(k);
    end;
    writeln(k-1);

end.

var  q,ans,x,y:longint;
function max(a,b:Longint):longint;
begin
 if a>b then max:=a else max:=b;
end;
begin
   readln(x,y);
  if (x=0) and (y=0) then writeln(0) else begin
   q:=max(abs(x),abs(y));
   ans:=4*(q-1);
   if (abs(x)=q) and (y>-x+1) and (x>0) then inc(ans,1)
   else if (abs(y)=q) and (x<y) and (y>0) then inc(ans,2)
   else if (abs(x)=q) and (x<0) and (y<-x) then inc(ans,3)
   else if (abs(y)=q) and (y<0) and (x>-y) then inc(ans,4);
   writeln(ans);
  end;
end.

{$APPTYPE CONSOLE}
program Project1;

uses
  SysUtils;

var
  x, y, r: integer;

begin
  if (ParamCount>0) and (ParamStr(1)='DEBUG') then begin
    AssignFile(Input, 'input.txt');
    Reset(Input);
    AssignFile(Output, 'output.txt');
    ReWrite(Output);
  end;

  ReadLn(x, y);
  if (y = 0) and ((x = 0) or (x = 1)) then
    r := 0
  else if (x > 0) and (y > -x + 1) and (y <= x) then
    r := 4 * (x - 1) + 1
  else if (y > 0) and (x >= -y ) and (x < y) then
    r := 4 * (y - 1) + 2
   else if (x < 0) and (y >= x) and (y < -x) then
     r := 4 * (-x - 1) + 3
   else if (y < 0) and (x > -y) and (x <= -y+1) then
     r := 4 * (-y - 1) + 4;

  Writeln(r);
end.

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils,
  Math;

var
  i, n, k, m, j, x, l, sk: integer;
  a: array [1..101, 1..101] of integer;
  c, d: array [1..101] of integer;

procedure Swap(var x, y: integer); overload;
var
  z: integer;
begin
  z := x;
  x := y;
  y := z;
end;

procedure Swap(var x, y: int64); overload;
var
  z: int64;
begin
  z := x;
  x := y;
  y := z;
end;

procedure Swap(var x, y: Extended); overload;
var
  z: extended;
begin
  z := x;
  x := y;
  y := z;
end;

procedure Swap(var x, y: real); overload;
var
  z: real;
begin
  z := x;
  x := y;
  y := z;
end;

procedure Swap(var x, y: double); overload;
var
  z: double;
begin
  z := x;
  x := y;
  y := z;
end;

procedure Swap(var x, y: boolean); overload;
var
  z: boolean;
begin
  z := x;
  x := y;
  y := z;
end;

procedure Swap(var x, y: byte); overload;
var
  z: byte;
begin
  z := x;
  x := y;
  y := z;
end;

begin
{$IFNDEF ONLINE_JUDGE}
  reset(input, 'input.txt');
  rewrite(output, 'output.txt');
{$ENDIF}
  read(n, m);
  sk := 0;
  for i := 1 to n do
    for j := 1 to m do
      a[i, j] := 0;
  for i := 1 to 100 do
    c[i] := 0;
  for i := 1 to 100 do
    d[i] := 0;
  for i := 1 to n do
  begin
    read(k);
    sk := sk + k;
    for j := 1 to k do
      begin
        read(x);
        a[i, x] := 1;
      end;
  end;
  if sk = 0 then
  begin
    write(n);
    exit;
  end
  else
    sk := n - 1;
  for i := 1 to n do
    c[i] := i;
  for i := 1 to n do
    for j := 1 to n do
      if c[j] <> c[i] then
      begin
        for k := 1 to m do
          if a[i, k] * a[j, k] = 1 then
            begin
              l := c[j];
              for x := 1 to n do
                if c[x] = l then
                  c[x] := c[i];
              dec(sk);
              break;

            end;
      end;
  x := 0;
  for i := 1 to n do
    d[c[i]] := 1;
  for i := 1 to n do
    x := x + d[i];
  write(x - 1);
end.

program Project1;
var
  x,y,x0,y0,kol:int64;
  i,j:longint;
 procedure d;
 begin
  { assign(input,'input.txt');reset(input);
   assign(output,'output.txt');rewrite(output);}
   i:=1;

  while (x0<>x) and (y0<>y) do begin
  if (x0<>x) and (y0<>y) then begin
   inc(x0,i);
   inc(kol);
   end;
   if (x0<>x) and (y0<>y) then begin
   inc(y0,i);inc(kol);
   end;

   inc(i);

   if (x0<>x) and (y0<>y) then begin

   dec(x0,i); inc(kol);  end;
   if (x0<>x) and (y0<>y) then begin
   dec(y0,i); inc(kol) end;

   inc(I);

  end;
 end;

begin

  readln(x,y);

  x0:=0;
  y0:=0;

  d;
  write(kol);

end.

{$APPTYPE CONSOLE}

uses
  SysUtils;
var  m,n,i,j,a,c,x,y,b:longint;

begin
//  assignfile(input,'INPUT.TXT'); reset(input);
//  assignfile(output,'OUTPUT.TXT'); rewrite(output);
  read(x,y);  i:=0; j:=0; m:=0; b:=0;
  if (x=0)and(y=1) then begin write(2); halt;  end;
  repeat
    inc(m); a:=i; c:=j;
    if m mod 2=1 then inc(b);
    if m mod 4=1 then inc(j,b);
    if m mod 4=2 then inc(i,b);
    if m mod 4=3 then dec(j,b);
    if m mod 4=0 then dec(i,b);
    if (a<=i) and (c<=j) then
    if (a<=x) and (x<=j) and (c<=y) and (y<=i) then break;
    if (a>=i) and (c<=j) then
    if (j<=x) and (x<=a) and (c<=y) and (y<=i) then break;
    if (a<=i) and (c>=j) then
    if (a<=x) and (x<=j) and (i<=y) and (y<=c) then break;
    if (a>=i) and (c>=j) then
    if (j<=x) and (x<=a) and (i<=y) and (y<=c) then break;
  until false;

  write(m-1);
  readln; readln;
end.

{$APPTYPE CONSOLE}

uses
  SysUtils;
var  m,n,i,j,a,c,x,y,b:longint;

begin
//  assignfile(input,'INPUT.TXT'); reset(input);
//  assignfile(output,'OUTPUT.TXT'); rewrite(output);
  read(x,y);  i:=0; j:=0; m:=0; b:=0;
  repeat
    inc(m); a:=i; c:=j;
    if m mod 2=1 then inc(b);
    if m mod 4=1 then inc(j,b);
    if m mod 4=2 then inc(i,b);
    if m mod 4=3 then dec(j,b);
    if m mod 4=0 then dec(i,b);
    if (a<=i) and (c<=j) then
    if (a<=x) and (x<=j) and (c<=y) and (y<=i) then break;
    if (a>=i) and (c<=j) then
    if (j<=x) and (x<=a) and (c<=y) and (y<=i) then break;
    if (a<=i) and (c>=j) then
    if (a<=x) and (x<=j) and (i<=y) and (y<=c) then break;
    if (a>=i) and (c>=j) then
    if (j<=x) and (x<=a) and (i<=y) and (y<=c) then break;
  until false;

  write(m-1);
  readln; readln;
end.

{$APPTYPE CONSOLE}

uses
  SysUtils;
var  m,n,i,j,a,c,x,y,b:longint;

begin
//  assignfile(input,'INPUT.TXT'); reset(input);
//  assignfile(output,'OUTPUT.TXT'); rewrite(output);
  read(x,y);  i:=0; j:=0; m:=0; b:=0;
  if x>y then n:=x else n:=y;

  repeat
    inc(m); a:=i; c:=j;
    if m mod 2=1 then inc(b);
    if m mod 4=1 then inc(j,b);
    if m mod 4=2 then inc(i,b);
    if m mod 4=3 then dec(j,b);
    if m mod 4=0 then dec(i,b);
    if (a<j) and (b<i) then
    if (a<=x) and (x<=j) and (c<=y) and (y<=i) then break;
    if (a>j) and (b<i) then
    if (j<=x) and (x<=a) and (c<=y) and (y<=i) then break;
    if (a<j) and (b>i) then
    if (a<=x) and (x<=j) and (i<=y) and (y<=c) then break;
    if (a>j) and (b>i) then
    if (j<=x) and (x<=a) and (i<=y) and (y<=c) then break;
  until false;

  write(m-1);
  readln; readln;
end.

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils,math;

type point = record x,y:integer; end;

{Procedure QSort(m, t: Integer);
Var i, j, x, w: Integer;
Begin
  i:=m; j:=t; x:=A[random(t-m+1)+m];
  Repeat
    While A[i]<x Do Inc(i);
    While A[j]>x Do Dec(j);
    If i<=j Then Begin
      w:=A[i]; A[i]:=A[j]; A[j]:=w;
      Inc(i); Dec(j);
    End
  Until i>j;
  If m<j Then QSort(m, j);
  If i<t Then QSort(i, t);
End;   }

           {
function gcd(a,b:integer):integer;
begin
if b=0 then gcd:=a
       else gcd:=gcd(b,a mod b);
end;

function search(str:string):integer;
var i,x:integer;
begin
x:=0;
for i:=1 to  do
 if team[i]=str then begin x:=i; break; end;
search:=x;
end;

}

var x,y,i,j,ans,t:integer;
    a:array[-100..100,-100..100] of boolean;

begin
readln(x,y);
if (x=0) and (y=0) then begin writeln('0'); halt; end;
if (x=0) and (y=1) then begin writeln('1'); halt; end;
if (x<0) and (y>=x) and (y<=-x+1) then begin writeln(-x*4); halt; end;
if (y>0) and (x>=-y+1) and (x<=y) then begin writeln(y*4-3); halt; end;
if (x>0) and (y>=-x) and (y<=x) then begin writeln(x*4-2); halt; end;
if (y<0) and (x>=y) and (x<=-y) then begin writeln(-y*4-1); halt; end;
end.

Var ans,a,b,x,y,i,n,m,d,k,z:LongInt;
Begin
 Read(a,b);
  while (x<>a)or(y<>b) do
   begin
    if d=0 then begin x:=-x; inc(x); end;
    if d=1 then begin y:=-y; inc(y); end;
    if d=2 then begin x:=-x; end;
    if d=3 then begin y:=-y; end;
     if d=3 then d:=0
     else inc(d);
     inc(ans);
     if (a=x)and(b>(-y))and(b<y) then begin z:=5;break;end;
     if (b=y)and(a>(-x))and(a<x) then begin z:=5; break; end;
   end;
   if z<>5 then dec(ans);
   if ans<0 then ans:=0;
  WriteLn(ans);
End.
                                      1

const dx:array[1..4] of longint=(1,0,-1,0);
      dy:array[1..4] of longint=(0,1,0,-1);

var x,y,xx,yy,kol,len,j,sost: longint;
begin
  readln(x,y);

  if (x=0) and (y=0) then
  begin
    writeln(0);
    halt;
  end;

  kol:=0;

  xx:=0;
  yy:=0;

  sost:=1;

  for len:=1 to 1000 do
    begin
      for j:=1 to len do
        begin
          xx:=xx+dx[sost];
          yy:=yy+dy[sost];
          if (xx=x) and (yy=y) then
          begin
            writeln(kol);
            halt;
          end;
        end;

      sost:=sost+1;
      sost:=sost mod 4;
      if sost=0 then sost:=4;

      inc(kol);
    end;

end.

var x,y,xx,yy,k,q,ans:longint;
 begin
  read (x,y);
  k:=1;
  xx:=0;
  yy:=0;
  q:=0;
  ans:=0;
  while true do
   begin
    if q=0 then begin
                 if (yy=y) and (xx+k>=x) then begin
                                               writeln (ans);
                                               halt(0);
                                              end
                                         else xx:=xx+k;
                end
           else begin
                 if (yy=y) and (xx-k<=x) then begin
                                               writeln (ans);
                                               halt(0);
                                              end
                                         else xx:=xx-k;
                end;
    inc (ans);
    if q=0 then begin
                 if (xx=x) and (yy+k>=y) then begin
                                               writeln (ans);
                                               halt(0);
                                              end
                                         else yy:=yy+k;
                end
           else begin
                 if (xx=x) and (yy-k<=y) then begin
                                               writeln (ans);
                                               halt(0);
                                              end
                                         else yy:=yy-k;
                end;
    inc (ans);
    q:=1-q;
    inc (k);
   end;
 end.

var i,q,n,it:longint;
    a:array[0..165] of longint;
    flag:boolean;
 begin
   read(i);
   for it:=i+1 to 9999 do
    begin
      q:=it;
      fillchar(a,sizeof(a),0);
      while q>0 do
       begin
         inc(a[q mod 10]);
         q:=q div 10;
       end;
      flag:=true;
      for i:=0 to 9 do
       if a[i]>1 then
        begin
          flag:=false;
          break;
        end;
      if flag then
      begin
        writeln(it);
        break;

      end;

    end;
 end.

Var  x,y,x1,y1,s,ans,i,c:integer;

Begin

  Readln( x , y );

  x1:=0;
  y1:=0;
  s:=1;
  ans:=0;
  c:=1;

  if ( x = 0 ) and ( y = 0 ) then begin

    writeln( 0 );
    Halt;

  end;

  While ( 1 <> 0 ) do begin

    for i:=1 to abs(s) do begin

      if ( s < 0 ) then x1:=x1-1
      Else inc ( x1 );

      if  ( x1 = x ) and ( y1 = y ) then begin

	inc ( ans );

        writeln ( ans );
	halt;

      end;

    end;

    if ( c <> 1 ) then inc ( ans );

    inc ( c );

    for i:=1 to abs(s) do begin

      if ( s < 0 ) then y1:=y1-1
      Else inc ( y1 );

      if  ( x1 = x ) and ( y1 = y ) then begin

        if ( c <> 1 ) then inc ( ans );
        writeln ( ans );
	halt;

      end;

    end;

    if ( c <> 1 ) then inc ( ans );

    if ( s > 0 ) then inc( s)
    Else begin

      s:=s*(-1);
      inc( s) ;
      s:=s*(-1);

    end;

    s:=s*(-1);

  end;

end.

Var x,y:longint;
    begin
      read(x,y);
      if (x>=0) and (y>=0) then begin
                                  if (x<=1) and (y=0) then begin writeln(0); halt; end;
                                  if x>=y then writeln((x-1)*4+1)
                                          else writeln((y-1)*4+2);
                                end
       else if (x<=0) and (y>=0) then begin
                                        if abs(x)<=y then writeln((y-1)*4+2)
                                                     else writeln((abs(x)-1)*4+3);
                                      end
       else if (x<=0) and (y<=0) then begin
                                       if abs(x)>=abs(y) then writeln((abs(x)-1)*4+3)
                                                         else writeln((abs(y))*4);
                                     end
       else if (x>=0) and (y<=0) then begin
                                        if x<=abs(y) then writeln(abs(y)*4)
                                                     else writeln((abs(x)-1)+1);
                                      end;
    end.

uses math;
Var x,y,q:int64;
   begin
        read(x,y);
         if (x>=0) and (y>=0) then begin
                               if (y=0) and (x<=1) then writeln(0)
                               else begin
                                 q:=max(x,y);
                               if x>=y then writeln((q-1)*4+1)
                                      else writeln((q-1)*4+2);
                                      end;
                             end
    else if (x<=0) and (y>=0) then begin
                                   q:=max(abs(x),y);
                                   if abs(x)>=y then writeln((q-1)*4+2)
                                               else writeln((q-1)*4+3)
                                 end
     else if (x<=0) and (y<=0) then begin
                                    q:=max(abs(x),abs(y));
                                    if (abs(x))>=abs(y) then writeln((q-1)*4+3)
                                     else writeln(q*4);
                                  end
     else if (x>=0) and (y<=0) then begin
                                    q:=max(abs(y),x);
                                    if x>abs(y) then writeln((q)*4+1)
                                    else writeln(q*4);
                                  end;
   end.

uses math;
Var x,y,q:int64;
   begin
        read(x,y);
         if (x>=0) and (y>=0) then begin
                               if (y=0) and (x<=1) then writeln(0)
                               else begin
                                 q:=max(x,y);
                               if x>=y then writeln((q-1)*4+1)
                                      else writeln((q-1)*4+2);
                                      end;
                             end
    else if (x<=0) and (y>=0) then begin
                                   q:=max(abs(x),y);
                                   if abs(x)>=y then writeln((q-1)*4+2)
                                               else writeln((q-1)*4+3)
                                 end
     else if (x<=0) and (y<=0) then begin
                                    q:=max(abs(x),abs(y));
                                    if (abs(x))>=abs(y) then writeln((q-1)*4+3)
                                     else writeln(q*4);
                                  end
     else if (x>=0) and (y<=0) then begin
                                    q:=abs(y);
                                    if x-abs(y)>1 then writeln((q)*4+1)
                                    else writeln(q*4);
                                  end;
   end.

var x,y,ans:longint;
begin
 read(x,y);
 ans:=(abs(x)-1)*4+1;
 if (x>0) and (y>0) then write(ans)
 else if (x>0) and (y<=0) then write(ans-1)
 else if (y>0) then write(ans+1)
 else write(ans+2);
end.

uses math;
var x,y,ans,k:longint;
begin
 read(x,y);
 k:=max(abs(x),abs(y));
  if (x=0) and (y=0) then begin write(0); halt; end;
 ans:=(k-1)*4+1;
 if (x=k) and (y<>-k+1) then write(ans)
 else if (x=k) then write(ans-1)
 else if (x=-k) and (y=k) then write(ans+1)
 else if (x=-k) then write(ans+2)
 else if (x<k) and (y=k) then write(ans+1)
 else write(ans+3);
end.

uses math;
var x,y,ans,k:longint;
begin
 read(x,y);
 k:=max(abs(x),abs(y));
  if (x=0) and (y=0) then begin write(0); halt; end;
 ans:=(k-1)*4+1;
 if (x=k) and (y<>-k+1) then write(ans)
 else if (x=k) then write(ans-1)
 else if (x=-k) and (y=k) then write(ans+1)
 else if (x=-k) then write(ans+2)
 else if (x<k) and (y=k) then write(ans)
 else write(ans+3);
end.

var  n,m,k,d,x,y:longint;
     s,s4:boolean;

begin
//assign(input,'input.txt');reset(input);
//assign(output,'output.txt');rewrite(output);
readln(n,m);
x:=1;y:=0;s:=false;d:=8;
k:=0;
if (m=0) and ((n=1) or (n=0)) then k:=0 else
while true do begin
      if d=8 then begin y:=-y;inc(y);d:=4;end else
         if d=4 then begin x:=-x;d:=2;end else
            if d=6 then begin x:=-x;inc(x);d:=8;end else
               begin y:=-y;d:=6;end;
      inc(k);
      if (y=m) and (x<=n) then break;
end;
write(k);
end.

var
	x,y,i,j,k,pov,l:longint;
begin
readln (x,y);
i:=0;
j:=0;
k:=0;
pov:=0;
while (x<>0) and (y<>0) do
begin
	inc (k);
	for l:=1 to k do
	begin

		inc (i);
		if (i=x) and (j=y) then
		begin
			writeln (pov);
			exit;
		end;

	end;	inc (pov);
	for l:=1 to k do
		begin

		inc (j);
		if (i=x) and (j=y) then
		begin
			writeln (pov);
			exit;
		end;

	end;inc (pov);
	inc (k);
	for l:=1 to k do
		begin

		dec (i);
		if (i=x) and (j=y) then
		begin
			writeln (pov);
			exit;
		end;

	end;
	inc (pov);
	for l:=1 to k do
		begin

		dec (j);
		if (i=x) and (j=y) then
		begin
			writeln (pov);
			exit;
		end;

	end;inc (pov);

end;
writeln ('0');
end.

var x,y,a,c,b,n,i,j:integer;f:boolean;
begin
read(x,y);
i:=0;
j:=0;
a:=1;
b:=1;
c:=b;
n:=0;
if (x=0) and (y=0) then Writeln('0')
else begin
repeat
f:=true;
if (a=1) and (f=true) then begin f:=false; inc(i);dec(c);if c=0 then begin a:=2;inc(n);c:=b; end;end;
if (a=2) and (f=true) then begin f:=false;  inc(j);dec(c);if c=0 then begin a:=3;inc(n);inc(b);c:=b; end;end;
if (a=3) and (f=true) then begin f:=false; dec(i);dec(c);if c=0 then begin a:=4; inc(n);c:=b;end;end;
if (a=4) and (f=true) then begin f:=false; dec(j);dec(c);if c=0 then begin a:=1; inc(n);inc(b);c:=b;end;end;

until (i=x) AND (j=y);
Writeln(n-1);
end;
end.

Var x,y,x1,y1,k,s,res,i:longint;
Begin
Readln(x,y);
If ((x=0) or (x=1)) and (y=0) Then Begin Writeln(0); Halt; End;
x1:=1; y1:=0;
s:=0;
k:=1;
res:=1;
While true do
 Begin
  If s=0 Then Begin For i:=1 to k do Begin inc(y1); If (x1=x) and (y=y1) Then Begin Writeln(res); Halt; End; End; inc(s); inc(res); inc(k); End;
  If s=1 Then Begin For i:=1 to k do Begin dec(x1); If (x1=x) and (y=y1) Then Begin Writeln(res); Halt; End; End; inc(s); inc(res); End;
  If s=2 Then Begin For i:=1 to k do Begin dec(y1); If (x1=x) and (y=y1) Then Begin Writeln(res); Halt; End; End; inc(s); inc(res); inc(k); End;
  If s=3 Then Begin For i:=1 to k do Begin inc(x1); If (x1=x) and (y=y1) Then Begin Writeln(res); Halt; End; End; inc(res); End;
  s:=s mod 3;
  inc(res);
 End;
End.

uses math;
var i,j,m,n,k,l,g,h,y,t,x:longint;
    a,b:array[1..1000]of longint;
begin   {
    assign(input,'input1.txt');
    reset(input);
    assign(output,'output1.txt');
    rewrite(output);}
    read(x,y);
    t:=max(abs(x),abs(y));
    if (x=0)and(y=0) then
    begin
        write(0);
        halt;
    end;
    if (x>=0)and(y>=0) then
    begin
        if x<y then
        k:=t*4-2
        else
        k:=t*4-3;
    end;
    if (x<0)and(y>0) then
    begin
        if abs(x)<=y then
        k:=t*4-2
        else
        k:=t*4-1;
    end;
    if (x<=0)and(y<=0) then
    begin
        if abs(x)>=abs(y) then
        k:=t*4-1
        else
        k:=t*4;
    end;
    if (x>0)and(y<0) then
    begin
        if abs(x)-1<=abs(y) then
        k:=(t-1)*4
        else
        k:=(t-1)*4+1;
    end;
    write(abs(k));
end.

uses math;
var i,j,m,n,k,l,g,h,y,t,x:longint;
    a,b:array[1..1000]of longint;
begin   {
    assign(input,'input1.txt');
    reset(input);
    assign(output,'output1.txt');
    rewrite(output);}
    read(x,y);
    t:=max(abs(x),abs(y));
    if (x=0)and(y=0) then
    begin
        write(0);
        halt;
    end;
    if (x>=0)and(y>0) then
    begin
        if x<y then
        k:=t*4-2
        else
        k:=t*4-3;
    end;
    if (x<0)and(y>=0) then
    begin
        if abs(x)<=y then
        k:=t*4-2
        else
        k:=t*4-1;
    end;
    if (x<=0)and(y<0) then
    begin
        if abs(x)>=abs(y) then
        k:=t*4-1
        else
        k:=t*4;
    end;
    if (x>0)and(y<=0) then
    begin
        if abs(x)-1<=abs(y) then
        k:=(t-1)*4
        else
        k:=(t-1)*4+1;
    end;
    write(abs(k));
end.

program ProblemA;
var a, b, x, y, i, d, ox, oy: longint;
    bool: boolean;
begin
 read(x, y);
 i:=0;
 a:=0;
 b:=0;
 d:=0;
 bool:=true;
 while bool do
  begin
   if (x = a) and (y = b) then bool:=false
   else
    begin
     inc(i);
     ox:=a;
     oy:=b;
     a:=a + i;
     if ((b = y) and (ox <= x) and (x <= a)) then bool:=false
     else
      begin
       ox:=a;
       inc(d);
       b:=b + i;
       if ((a = x) and (oy <= y) and (y <= b)) then bool:=false
       else
        begin
         oy:=b;
         inc(i);
         inc(d);
         a:=a - i;
         if ((b = y) and (ox >= x) and (x >= a)) then bool:=false
         else
          begin
           ox:=a;
           inc(d);
           b:=b - i;
           if ((a = x) and (oy >= y) and (y >= b)) then bool:=false
          end;
        end;
      end;
    end;
  end;
 write(d);
end.

program ProblemA;
var a, b, x, y, i, d, ox, oy: longint;
    bool: boolean;
function Check: boolean;
 begin
  if (a <> x) or (b <> y) then Check:=true
  else Check:=false;
 end;
begin
 read(x, y);
 i:=0;
 a:=0;
 b:=0;
 d:=0;
 bool:=true;
 while bool do
  begin
   ox:=a;
   oy:=b;
   inc(i);
   a:=a + i;
   if not((b = y) and ((ox <= x) and (a >= x))) then
    begin
     ox:=a;
     inc(d);
     b:=b + i;
     if not((a = x) and ((oy <= y) and (b >= y))) then
      begin
       oy:=b;
       inc(i);
       inc(d);
       a:=a - i;
       if not((b = y) and ((a <= x) and (ox >= x))) then
        begin
         ox:=a;
         inc(d);
         b:=b - i;
         oy:=b;
        end
       else bool:=false;
      end
     else bool:=false;
    end
   else bool:=false;
  end;
 write(d);
end.

{$mode objfpc}

uses math;

const
        fi = '';//'171a2.inp';
        fo = '';//'171a2.out';

var
        x,y: integer;
        res,round: integer;

procedure enter;
begin
        readln(x,y);
        if (x=0) and (y=0) then
           begin
                writeln('0');
                halt;
           end;
        round:=max(abs(x),abs(y));
        res:=round*4;
        if abs(y)=round then
           begin
                if y>0 then res:=res-2;
           end
        else if abs(x)=round then
           begin
                if x>0 then res:=res-3;
                if x<0 then res:=res-1;
           end;
        if (x>0) and (y<=0) and (abs(y)+1=x) then dec(res);
        writeln(res);
end;

begin
        assign(input,fi);reset(input);
        assign(output,fo);rewrite(output);

        enter;
end.

{$mode objfpc}

uses math;

const
        fi = '';//'171a2.inp';
        fo = '';//'171a2.out';

var
        x,y: integer;
        res,round: integer;

procedure enter;
begin
        readln(x,y);
        if (x=0) and (y=0) then
           begin
                writeln('0');
                halt;
           end;
        round:=max(abs(x),abs(y));
        res:=(round-1)*4;
        if round=abs(x) then
           begin
                if x>0 then res:=res+1;
                if x<0 then res:=res+3;
           end
        else
           begin
                if y>0 then res:=res+2;
           end;
        if (x>0) and (abs(y)=x-1) then deC(res);
        if abs(x)=abs(y) then dec(res);
        writeln(res);
end;

begin
        assign(input,fi);reset(input);
        assign(output,fo);rewrite(output);

        enter;
end.

{$mode objfpc}

uses math;

const
        fi = '';//'171a2.inp';
        fo = '';//'171a2.out';

var
        x,y: integer;
        res,round: integer;

procedure enter;
begin
        readln(x,y);
        if (x=0) and (y=0) then
           begin
                writeln('0');
                halt;
           end;
        round:=max(abs(x),abs(y));
        res:=(round-1)*4;
        if round=abs(x) then
           begin
                if x>0 then res:=res+1;
                if x<0 then res:=res+3;
           end
        else
           begin
                if y>0 then res:=res+2;
           end;
        if (x>0) and (abs(y)=x-1) then deC(res);
        writeln(res);
end;

begin
        assign(input,fi);reset(input);
        assign(output,fo);rewrite(output);

        enter;
end.

{$mode objfpc}

uses math;

const
        fi = '';//'171a2.inp';
        fo = '';//'171a2.out';

var
        x,y: integer;
        res,round: integer;

procedure enter;
begin
        readln(x,y);
        if (x=0) and (y=0) then
           begin
                writeln('0');
                halt;
           end;
        round:=max(abs(x),abs(y));
        res:=round*4;
        if abs(y)=round then
           begin
                if y>0 then res:=res-2;
           end
        else if abs(x)=round then
           begin
                if x>0 then res:=res-3;
                if x<0 then res:=res-1;
           end;
        if (x>0) and (y>0) and (x=y) then dec(res);
        if (x>0) and (y<=0) and (abs(y)+1=x) then dec(res);
        writeln(res);
end;

begin
        assign(input,fi);reset(input);
        assign(output,fo);rewrite(output);

        enter;
end.

program amocana;
var x,y:integer;
begin
read(x,y);
if abs(y)>=abs(x) then write(4*y-2) else
if abs(y)<=abs(x) then write(4*abs(x)-1) else
if (x=0) and (y=0) then write(0);
end.

program amocana;
var x,y:integer;
begin
read(x,y);
if (y=0) and (x=0) then write(0);
if (y>x) and (-x<y) then write(4*y-2);
if (y>=x) and (-x>y) then write(-4*x-1);
if (y<x) and (y<=-x+1) then write(-4*y);
if (y<=x) and (y>-x+1) then write(4*x-3);
end.

var x,y,i:longint;s1,s2:int64;
begin
readln(x,y);
if (x=0)and(y=0)
then begin
     writeln(0);
     exit;
     end;
for i:=1 to abs(y) do
s1:=s1+4;
for i:=1 to abs(x) do
s2:=s2+4;
if (x>y)and(x-1<=abs(y))and(y<0)
then writeln(s1)
else if ((x=y)or(abs(x)>y))and(x<0)
     then writeln(s2-1)
     else if y>x
          then writeln(s1-2)
          else writeln(s2-3);
end.

var x,y,i:longint;s1,s2:longint;
begin
readln(x,y);
for i:=1 to abs(y) do
s1:=s1+4;
for i:=1 to abs(x) do
s2:=s2+4;
if (x>y)and(x-1<=abs(y))
then writeln(s1)
else if ((x=y)or(abs(x)>y))and(x<0)
     then writeln(s2-1)
     else if y>x
          then writeln(s1-2)
          else writeln(s2-3);
end.

var
 a:array[-3..3,-3..3] of longint;
 i,j,k,x,y:longint;
begin
readln(x,y);
if (y=0)and((x=1)or(x=0)) then
 begin
  writeln(0);
  halt;
 end;
a[0,0]:=-1;
a[0,1]:=-1;
i:=0;
j:=1;
k:=0;
while (j<>x)or(i<>y) do
 begin
  inc(k);
  while a[i,j-1]=-1 do
   begin
    inc(i);
    a[i,j]:=-1;
    if (j=x)and(i=y) then
     begin
      write(k);
      halt;
     end;
   end;
  inc(k);
  while a[i-1,j]=-1 do
   begin
    dec(j);
    a[i,j]:=-1;
    if (j=x)and(i=y) then
     begin
      write(k);
      halt;
     end;
   end;
  inc(k);
  while a[i,j+1]=-1 do
   begin
    dec(i);
    a[i,j]:=-1;
    if (j=x)and(i=y) then
     begin
      write(k);
      halt;
     end;
   end;
  inc(k);
  while a[i+1,j]=-1 do
   begin
    inc(j);
    a[i,j]:=-1;
    if (j=x)and(i=y) then
     begin
      write(k);
      halt;
     end;
   end;
 end;
end.

function mog(n,m : longint) : integer;
begin
if m<0 then m:=m*-1;
if n<0 then n:=n*-1;
if n>m then mog:=1;
if m>n then mog:=2;
//if n=m then mog:=0;
end;
var i,i2,n,m,x,y,ans : longint;
        c : char;
begin
readln(x,y);
if (x<0) and (mog(x,y)=1) and (y<>x*-1) then c:='l';
if (x>0) and (mog(x,y)=1) and (y<>(x-1)*-1) and (y<>x*-1) then c:='r';
if (y>0) and (mog(x,y)=2) and (x<>y*-1) then c:='u';
if (y<0) and ( (mog(x,y)=2) or (mog(x,y)=1) and (x=(y*-1)+1) ) and (x<>y) then c:='d';

if c='r' then ans:=x*4-3;
if c='l' then ans:=(x*-1)*4-1;
if c='d' then ans:=(y*-1)*4;
if c='u' then ans:=y*4-2;
writeln(ans);
readln;
end.

function mog(n,m : longint) : integer;
begin
if m<0 then m:=m*-1;
if n<0 then n:=n*-1;
if n>=m then mog:=1;
if m>n then mog:=2;
//if n=m then mog:=0;
end;
var i,i2,n,m,x,y,ans : longint;
        c : char;
begin
readln(x,y);
if (x<0) and (mog(x,y)=1) and (y<>x*-1) then c:='l';
if (x>0) and (mog(x,y)=1) and (y<>(x-1)*-1) and (y<>x*-1) then c:='r';
if (y>0) and (mog(x,y)=2) and (x<>y*-1) then c:='u';
if (y<0) and ( (mog(x,y)=2) or (mog(x,y)=1) and (x=(y*-1)+1) ) and (x<>y) then c:='d';

if c='r' then ans:=x*4-3;
if c='l' then ans:=(x*-1)*4-1;
if c='d' then ans:=(y*-1)*4;
if c='u' then ans:=y*4-2;
writeln(ans);
readln;
end.

var i,j,k:longint;
 begin
  read(i,j);
     k:=0;

   if (i=j)and(i>0) then k:=(abs(i)-1)*4+1;
   if (i=j)and(j<0) then k:=(abs(i)-1)*4+3;

   if (i>j) then k:=(abs(i)-1)*4;
   if (i<j) then k:=(abs(j)-1)*4+2;

     writeln(k);

  end.

var i,j,k:longint;
 begin
  read(i,j);

   if (i=j)and(i>0) then k:=(abs(i)-1)*4+1;
   if (i=j)and(j<0) then k:=(abs(i)-1)*4+3;

   if (i>j) then k:=(abs(i)-1)*4;
   if (i<j) then k:=(abs(j)-1)*4+2;

     writeln(k);

  end.

{$mode objfpc}

var             x , y , yl , yh , res       :       integer;

begin
                readln( x , y ); res := 0;
                if ( x = 0 ) and ( y = 0 ) then
                        begin
                                writeln( 0 );
                                exit;
                        end;
                if x > 0 then
                        begin
                                yl := -( x - 1 );
                                yh := x;
                                res := ( x - 1 ) * 4;
                                if y = yl then
                                        begin
                                                writeln( res );
                                                exit;
                                        end;
                                if ( yl < y ) and ( y <= yh ) then
                                        begin
                                                writeln( res + 1 );
                                                exit;
                                        end;
                                if y < yl then
                                        begin
                                                writeln( res + ( abs( y ) - x + 1 ) * 4 );
                                                exit;
                                        end;
                                if y > yh then
                                        begin
                                                writeln( res + ( y - yh ) * 4 + 2 );
                                                exit;
                                        end;
                        end;
                if x < 0 then
                        begin
                                yl := x; yh := -x;
                                res := yh * 4 - 2;
                                if y = yh then
                                        begin
                                                writeln( res );
                                                exit;
                                        end;
                                if ( y >= yl ) and ( y < yh ) then
                                        begin
                                                writeln( res + 1 );
                                                exit;
                                        end;
                                if y > yh then
                                        begin
                                                writeln( res + 4 * ( y - yh ) );
                                                exit;
                                        end;
                                if y < yl then
                                        begin
                                                writeln( res + 4 * ( yl - y ) + 1 );
                                                exit;
                                        end;
                        end;
                if x = 0 then
                        begin
                                if y > 0 then
                                        begin
                                                writeln( 2 + 5 * ( y - 1 ) );
                                                exit;
                                        end;
                                if y < 0 then
                                        begin
                                                writeln( 4 + 5 * ( abs( y ) - 1 ) );
                                                exit;
                                        end;
                        end;
end.

{$mode objfpc}

var             x , y , yl , yh , res       :       integer;

begin
                readln( x , y ); res := 0;
                if ( x = 0 ) and ( y = 0 ) then
                        begin
                                writeln( 0 );
                                exit;
                        end;
                if x > 0 then
                        begin
                                yl := -( x - 1 );
                                yh := x; res := ( x - 1 ) * 4;
                                if y = yl then
                                        begin
                                                writeln( res );
                                                exit;
                                        end;
                                if ( yl < x ) and ( x <= yh ) then
                                        begin
                                                writeln( res + 1 );
                                                exit;
                                        end;
                                if y < yl then
                                        begin
                                                writeln( res + ( abs( y ) - x + 1 ) * 4 );
                                                exit;
                                        end;
                                if y > yh then
                                        begin
                                                writeln( res + ( y - yh ) * 4 + 2 );
                                                exit;
                                        end;
                        end;
                if x < 0 then
                        begin
                                yl := x; yh := -x;
                                res := yh * 4 - 2;
                                if y = yh then
                                        begin
                                                writeln( res );
                                                exit;
                                        end;
                                if ( y >= yl ) and ( y < yh ) then
                                        begin
                                                writeln( res + 1 );
                                                exit;
                                        end;
                                if y > yh then
                                        begin
                                                writeln( res + 4 * ( y - yh ) );
                                                exit;
                                        end;
                                if y < yl then
                                        begin
                                                writeln( res + 4 * ( yl - y ) + 1 );
                                                exit;
                                        end;
                        end;
                if x = 0 then
                        begin
                                if y > 0 then
                                        begin
                                                writeln( 2 + 5 * ( y - 1 ) );
                                                exit;
                                        end;
                                if y < 0 then
                                        begin
                                                writeln( 4 + 5 * ( abs( y ) - 1 ) );
                                                exit;
                                        end;
                        end;
end.

{$mode objfpc}

var             x , y , yl , yh , res       :       integer;

begin
                readln( x , y ); res := 0;
                if ( x = 0 ) and ( y = 0 ) then
                        begin
                                writeln( 0 );
                                exit;
                        end;
                if x > 0 then
                        begin
                                yl := -( x - 1 );
                                yh := x;
                                res := ( x - 1 ) * 4;
                                if y = yl then
                                        begin
                                                writeln( res );
                                                exit;
                                        end;
                                if ( yl < y ) and ( y <= yh ) then
                                        begin
                                                writeln( res + 1 );
                                                exit;
                                        end;
                                if y < yl then
                                        begin
                                                writeln( res + ( abs( y ) - x + 1 ) * 4 );
                                                exit;
                                        end;
                                if y > yh then
                                        begin
                                                writeln( res + ( y - yh ) * 4 + 2 );
                                                exit;
                                        end;
                        end;
                if x < 0 then
                        begin
                                yl := x; yh := -x;
                                res := yh * 4 - 2;
                                if y = yh then
                                        begin
                                                writeln( res );
                                                exit;
                                        end;
                                if ( y >= yl ) and ( y < yh ) then
                                        begin
                                                writeln( res + 1 );
                                                exit;
                                        end;
                                if y > yh then
                                        begin
                                                writeln( res + 4 * ( y - yh ) );
                                                exit;
                                        end;
                                if y < yl then
                                        begin
                                                writeln( res + 4 * ( yl - y ) + 2 );
                                                exit;
                                        end;
                        end;
                if x = 0 then
                        begin
                                if y > 0 then
                                        begin
                                                writeln( 2 + 5 * ( y - 1 ) );
                                                exit;
                                        end;
                                if y < 0 then
                                        begin
                                                writeln( 4 + 5 * ( abs( y ) - 1 ) );
                                                exit;
                                        end;
                        end;
end.

var i, j, ans:longint;
begin
// assign(input, 'input.txt');reset(input);
// assign(output, 'output.txt');rewrite(output);

  readln(i, j);
  ans:=0;
  if (j<=i)and(j>=(-i+2)) then ans:=(i-1)*4+1;
  if (i>=(-j))and(i<=(j-1)) then ans:=(j-1)*4+2;
  if (j<=(abs(i)-1))and(j>=i) then ans:=(abs(i)-1)*4+3;
  if (i<=(abs(j)+1))and(i>=(j+1)) then ans:=(abs(j)-1)*4+4;

  //f x=0
  writeln(ans);
// close(input);close(output);
end.

var x,y,z:shortint; turn:word=0;
begin
        read(x,y);
        z:=y;
        while z<>0 do
        begin
                inc(turn,2);
                if z>0 then z:=1-z
                else z:=-z
        end;
        if (x=y) and (x<>0) then dec(turn);
        write(turn)
end.

program kon;

{$mode objfpc}{$H+}

var x, y, ans: integer;

begin
 { assign(input, 'input.txt');
  assign(output, 'output.txt');
  reset(input);
  rewrite(output);   }
  read(x, y);

  if (x=y) and (x<0) then
  ans:=abs(x)*4-1;

  if (x>y) and (y<0) then
  ans:=4*abs(y);

  if (x>=y) and (x>0) and (-(x-1)<>y) then
  ans:=ans+(x-1)*4+1;

  if (y>x) then
  ans:=(y-1)*4+2;

  if (x<0) and (abs(x)>abs(y)) then
  ans:=(abs(x)-1)*4+3;

  write(ans);
{  close(input);
  close(output);  }
  end.

program ex;
var
x,y:integer;
i,j,kx,ky,m:longint;
a,b:integer;
flag:booleaN;
begin
readln(kx,ky);
m:=0;
x:=0;
y:=0;
a:=0;
b:=0;
flag:=true;
while (x<>kx)or(y<>ky) do begin
if flag then begin
if a>=0 then inc(a);
if a>0 then for i:=1 to a do begin inc(x); if (x=kx)and(y=ky) then begin write(m);exit;end;end;
if a<0 then dec(a);
if a<0 then for i:=-1 downto a do begin dec(x); if (x=kx)and(y=ky) then begin write(m);exit;end; end;
a:=-a;end
else begin if b>=0 then inc(b);
if b>0 then for i:=1 to b do begin inc(y); if (x=kx)and(y=ky) then begin write(m);exit;end; end;
if b<0 then dec(b);
if b<0 then for i:=-1 downto b do begin dec(y); if (x=kx)and(y=ky) then begin write(m);exit;end; end;
b:=-b; end;
inc(m);

flag:=not flag;
end;

end.

var
  x,y,startX,startY:integer;
    counter:integer;
Begin
read(x,y);//oo-start
if (x=1) and (y=0) then begin counter:=0;
writeln(counter);
exit;
end;
if (x>=0) and (y>=-x+1) and (y<=x) then
 counter:=4*(x-1)+1;
if (x<=0) and (y<=-x) and (y>=x) then
 counter:=4*(-x)-1;
if (y>=0) and (x>=-y) and (x<=y) then
  counter:=4*y-2;
if (y<=0) and (x>=-y) and (x<=-y+1) then
  counter:=4*(-y);
 writeln(counter);
end.

var
  x,y,startX,startY:integer;
    counter:integer;
Begin
read(x,y);//oo-start
if (x=1) and (y=0) then begin counter:=0;
writeln(counter);
exit;
end;
if (x=1) and (y=1) then begin counter:=1;
writeln(counter);
exit;
end;
if (x=0) and (y=-1) then begin counter:=4;
writeln(counter);
exit;
end;

if (x>=0) and (y>=-x+1) and (y<x) then
 counter:=4*(x-1)+1;
if (x<=0) and (y<=-x) and (y>=x) then
 counter:=4*(-x)-1;
if (y>=0) and (x>=-y) and (x<y) then
  counter:=4*y-2;
if (y<=0) and (x>y) and (x<=-y+1) then
  counter:=4*(-y);
 writeln(counter);
end.

var x,y,x1,y1,k:longint;
begin
  readln(x,y);
  if (x=0) and (y=0) then k:=0
    else if (x=1) and (y=0) then k:=0
      else if (x=1) and (y=1) then k:=1
        else if (x=0) and (y=1) then k:=2
          else if (x=-1) and (y=1) then k:=2
            else if (x=-1) and (y=0) then k:=3
              else if (x=-1) and (y=-1) then k:=3
                else if (x=0) and (y=-1) then k:=4
                  else if (x=1) and (y=-1) then k:=4
                    else if (x=2) and (y=-1) then k:=4
                      ELSE
                      BEGIN
                        x1:=abs(x);
                        y1:=abs(y);
                        if (x1>y1) then BeGiN if (x>0) then k:=1+(x1-1)*4
                                                       else k:=3+(x1-1)*4
                                        EnD
                            else        BeGiN if (y>0) then k:=2+(y1-1)*4
                                                                else k:=4+(y1-1)*4;
                                        EnD;
                      END;
  writeln(k);
end.