{
TASK:water
LANG:pascal
}
{$R-}
type data = record x,y:longint;end;
type data1 = record r:array[0..6,1..3] of longint;broi:longint;end;
var a:array[1..3] of data;
    n,k:longint;
    t:array[1..1000000] of data1;
    pr,j,a1,a2,a3,b1,b2,b3,code,k1:longint;
    i,br,st,fin,p,q:longint;
    ot:array[1..1000000] of longint;
Function Check(y:longint):boolean;
var z,fl:longint;
begin
   fl:=0;
   for z:=0 to t[y].broi do
      if (t[y].r[z,1]=b1)and(t[y].r[z,2]=b2)and(t[y].r[z,3]=b3) then fl:=1;
   if fl = 1 then Check:=false
   else Check:=true;

end;
Procedure Fill(e,e1:longint);
begin
   for i:=0 to t[e].broi do
      begin
         t[e1].r[i,1]:=t[e].r[i,1];
         t[e1].r[i,2]:=t[e].r[i,2];
         t[e1].r[i,3]:=t[e].r[i,3];
      end;
end;
begin

   readln(n,k);
   for i:=1 to 2 do read(a[i].x,a[i].y);
   readln(a[3].x,a[3].y);
   if k = 1 then
     begin
        br:=0;
        if a[1].x=1 then inc(br);
        if a[1].y=1 then inc(br);
        if a[2].x=1 then inc(br);
        if a[2].y=1 then inc(br);
        if a[3].x=1 then inc(br);
        if a[3].y=1 then inc(br);
        if a[1].x=n-1 then inc(br);
        if a[1].y=n-1 then inc(br);
        if a[2].x=n-1 then inc(br);
        if a[2].y=n-1 then inc(br);
        if a[3].x=n-1 then inc(br);
        if a[3].y=n-1 then inc(br);
        writeln(br);
     end
   else
      begin
        st:=0;
        br:=0;
        fin:=1;
        t[1].broi:=0;
        t[1].r[0,1]:=n;
        t[1].r[0,2]:=0;
        t[1].r[0,3]:=0;
        while st<fin do
           begin
              inc(st);
              p:=t[st].broi;

              if (t[st].r[p,1]=1)or(t[st].r[p,2]=1)or(t[st].r[p,3]=1)and(p<=k) then
                 begin
                    if br = 0 then
                       begin
                          inc(br);
                          ot[1]:=st;
                       end
                    else begin
                    i:=0;
                    repeat
                       inc(i);
                       j:=0;
                       code:=0;
                       repeat
                          inc(j);
                          if t[ot[i]].r[j,1]=t[st].r[j,1] then code:=code+1
                          else code:=0;
                          if t[ot[i]].r[j,2]=t[st].r[j,2] then code:=code+1
                          else code:=0;
                          if t[ot[i]].r[j,3]=t[st].r[j,3] then code:=code+1
                          else code:=0;
                       until (j =t[ot[i]].broi)or(code<3);
                    until (code>3)or(i=br);
                    if code < 3 then
                       begin
                          inc(br);
                          ot[br]:=st;
                       end;   end;
                 end
               else if p+1<=k then
                 begin
                    q:=t[st].broi;
                    a1:=t[st].r[q,1];
                    a2:=t[st].r[q,2];
                    a3:=t[st].r[q,3];

                    b1:=0;
                    b2:=a1+a2;
                    b3:=a3;
                    if Check(st) = true then
                       begin
                          inc(fin);
                          Fill(st,fin);
                          t[fin].broi:=q+1;
                          t[fin].r[q+1,1]:=b1;
                          t[fin].r[q+1,2]:=b2;
                          t[fin].r[q+1,3]:=b3;
                       end;

                    b1:=0;
                    b2:=a2;
                    b3:=a1+a3;
                    if Check(st) = true then
                       begin
                          inc(fin);
                          Fill(st,fin);
                          t[fin].broi:=q+1;
                          t[fin].r[q+1,1]:=b1;
                          t[fin].r[q+1,2]:=b2;
                          t[fin].r[q+1,3]:=b3;
                       end;

                    b1:=a1+a2;
                    b2:=0;
                    b3:=a3;
                    if Check(st) = true then
                       begin
                          inc(fin);
                          Fill(st,fin);
                          t[fin].broi:=q+1;
                          t[fin].r[q+1,1]:=b1;
                          t[fin].r[q+1,2]:=b2;
                          t[fin].r[q+1,3]:=b3;
                       end;

                    b1:=a1;
                    b2:=0;
                    b3:=a2+a3;
                    if Check(st) = true then
                       begin
                          inc(fin);
                          Fill(st,fin);
                          t[fin].broi:=q+1;
                          t[fin].r[q+1,1]:=b1;
                          t[fin].r[q+1,2]:=b2;
                          t[fin].r[q+1,3]:=b3;
                       end;

                    b1:=a1+a3;
                    b2:=a2;
                    b3:=0;
                    if Check(st) = true then
                       begin
                          inc(fin);
                          Fill(st,fin);
                          t[fin].broi:=q+1;
                          t[fin].r[q+1,1]:=b1;
                          t[fin].r[q+1,2]:=b2;
                          t[fin].r[q+1,3]:=b3;
                       end;

                    b1:=a1;
                    b2:=a2+a3;
                    b3:=0;
                    if Check(st) = true then
                       begin
                          inc(fin);
                          Fill(st,fin);
                          t[fin].broi:=q+1;
                          t[fin].r[q+1,1]:=b1;
                          t[fin].r[q+1,2]:=b2;
                          t[fin].r[q+1,3]:=b3;
                       end;

                    if (a2<a[2].x)and(a1+a2>=a[2].x) then
                       begin
                          b1:=a1+a2-a[2].x;
                          b2:=a[2].x;
                          b3:=a3;
                    if Check(st) = true then
                       begin
                          inc(fin);
                          Fill(st,fin);
                          t[fin].broi:=q+1;
                          t[fin].r[q+1,1]:=b1;
                          t[fin].r[q+1,2]:=b2;
                          t[fin].r[q+1,3]:=b3;
                       end;
                       end;
                    if (a2<a[2].y)and(a1+a2>=a[2].y) then
                       begin
                          b1:=a1+a2-a[2].y;
                          b2:=a[2].y;
                          b3:=a3;
                    if Check(st) = true then
                       begin
                          inc(fin);
                          Fill(st,fin);
                          t[fin].broi:=q+1;
                          t[fin].r[q+1,1]:=b1;
                          t[fin].r[q+1,2]:=b2;
                          t[fin].r[q+1,3]:=b3;
                       end;
                       end;
                    if (a3<a[3].x)and(a1+a3>=a[3].x) then
                       begin
                          b1:=a1+a3-a[3].x;
                          b2:=a2;
                          b3:=a[3].x;
                    if Check(st) = true then
                       begin
                          inc(fin);
                          Fill(st,fin);
                          t[fin].broi:=q+1;
                          t[fin].r[q+1,1]:=b1;
                          t[fin].r[q+1,2]:=b2;
                          t[fin].r[q+1,3]:=b3;
                       end;
                       end;
                    if (a3<a[3].y)and(a1+a3>=a[3].y) then
                       begin
                          b1:=a1+a3-a[3].y;
                          b2:=a2;
                          b3:=a[3].y;
                    if Check(st) = true then
                       begin
                          inc(fin);
                          Fill(st,fin);
                          t[fin].broi:=q+1;
                          t[fin].r[q+1,1]:=b1;
                          t[fin].r[q+1,2]:=b2;
                          t[fin].r[q+1,3]:=b3;
                       end;
                       end;

                    if (a1<a[1].x)and(a1+a2>=a[1].x) then
                       begin
                          b1:=a[1].x;
                          b2:=a1+a2-b1;
                          b3:=a3;
                    if Check(st) = true then
                       begin
                          inc(fin);
                          Fill(st,fin);
                          t[fin].broi:=q+1;
                          t[fin].r[q+1,1]:=b1;
                          t[fin].r[q+1,2]:=b2;
                          t[fin].r[q+1,3]:=b3;
                       end;
                       end;
                    if (a1<a[1].y)and(a1+a2>=a[1].y) then
                       begin
                          b1:=a[1].y;
                          b2:=a1+a2-b1;
                          b3:=a3;
                    if Check(st) = true then
                       begin
                          inc(fin);
                          Fill(st,fin);
                          t[fin].broi:=q+1;
                          t[fin].r[q+1,1]:=b1;
                          t[fin].r[q+1,2]:=b2;
                          t[fin].r[q+1,3]:=b3;
                       end;
                       end;
                    if (a3<a[3].x)and(a2+a3>=a[3].x) then
                       begin
                          b1:=a1;
                          b2:=a2+a3-a[3].x;
                          b3:=a[3].x;
                    if Check(st) = true then
                       begin
                          inc(fin);
                          Fill(st,fin);
                          t[fin].broi:=q+1;
                          t[fin].r[q+1,1]:=b1;
                          t[fin].r[q+1,2]:=b2;
                          t[fin].r[q+1,3]:=b3;
                       end;
                       end;
                    if (a3<a[3].y)and(a2+a3>=a[3].y) then
                       begin
                          b1:=a1;
                          b2:=a2+a3-a[3].y;
                          b3:=a[3].y;
                    if Check(st) = true then
                       begin
                          inc(fin);
                          Fill(st,fin);
                          t[fin].broi:=q+1;
                          t[fin].r[q+1,1]:=b1;
                          t[fin].r[q+1,2]:=b2;
                          t[fin].r[q+1,3]:=b3;
                       end;
                       end;

                    if (a1<a[1].x)and(a1+a3>=a[1].x) then
                       begin
                          b1:=a[1].x;
                          b2:=a2;
                          b3:=a3+a1-b1;
                    if Check(st) = true then
                       begin
                          inc(fin);
                          Fill(st,fin);
                          t[fin].broi:=q+1;
                          t[fin].r[q+1,1]:=b1;
                          t[fin].r[q+1,2]:=b2;
                          t[fin].r[q+1,3]:=b3;
                       end;
                       end;
                    if (a2<a[1].y)and(a1+a3>=a[1].y) then
                       begin
                          b1:=a[1].y;
                          b2:=a2;
                          b3:=a3+a1-b1;
                    if Check(st) = true then
                       begin
                          inc(fin);
                          Fill(st,fin);
                          t[fin].broi:=q+1;
                          t[fin].r[q+1,1]:=b1;
                          t[fin].r[q+1,2]:=b2;
                          t[fin].r[q+1,3]:=b3;
                       end;
                       end;
                    if (a2<a[2].x)and(a2+a3>=a[2].x) then
                       begin
                          b1:=a1;
                          b2:=a[2].x;
                          b3:=a2+a3-b2;
                    if Check(st) = true then
                       begin
                          inc(fin);
                          Fill(st,fin);
                          t[fin].broi:=q+1;
                          t[fin].r[q+1,1]:=b1;
                          t[fin].r[q+1,2]:=b2;
                          t[fin].r[q+1,3]:=b3;
                       end;
                       end;
                    if (a2<a[2].y)and(a2+a3>=a[2].y) then
                       begin
                          b1:=a1;
                          b2:=a[2].y;
                          b3:=a2+a3-b2;
                    if Check(st) = true then
                       begin
                          inc(fin);
                          Fill(st,fin);
                          t[fin].broi:=q+1;
                          t[fin].r[q+1,1]:=b1;
                          t[fin].r[q+1,2]:=b2;
                          t[fin].r[q+1,3]:=b3;
                       end;
                       end;

                    if a1>a[1].x then
                       begin
                          b1:=a[1].x;
                          b2:=a2+a1-b1;
                          b3:=a3;
                    if Check(st) = true then
                       begin
                          inc(fin);
                          Fill(st,fin);
                          t[fin].broi:=q+1;
                          t[fin].r[q+1,1]:=b1;
                          t[fin].r[q+1,2]:=b2;
                          t[fin].r[q+1,3]:=b3;
                       end;
                          b2:=a2;
                          b3:=a3+a1-b1;
                    if Check(st) = true then
                       begin
                          inc(fin);
                          Fill(st,fin);
                          t[fin].broi:=q+1;
                          t[fin].r[q+1,1]:=b1;
                          t[fin].r[q+1,2]:=b2;
                          t[fin].r[q+1,3]:=b3;
                       end;


                       end;
                    if a1>a[1].y then
                       begin
                          b1:=a[1].y;
                          b2:=a2+a1-b1;
                          b3:=a3;
                    if Check(st) = true then
                       begin
                          inc(fin);
                          Fill(st,fin);
                          t[fin].broi:=q+1;
                          t[fin].r[q+1,1]:=b1;
                          t[fin].r[q+1,2]:=b2;
                          t[fin].r[q+1,3]:=b3;
                       end;
                          b2:=a2;
                          b3:=a3+a1-b1;
                    if Check(st) = true then
                       begin
                          inc(fin);
                          Fill(st,fin);
                          t[fin].broi:=q+1;
                          t[fin].r[q+1,1]:=b1;
                          t[fin].r[q+1,2]:=b2;
                          t[fin].r[q+1,3]:=b3;

                       end;
                       end;
                    if a2>a[2].x then
                       begin
                          b2:=a[2].x;
                          b1:=a1+a2-b2;
                          b3:=a3;
                    if Check(st) = true then
                       begin
                          inc(fin);
                          Fill(st,fin);
                          t[fin].broi:=q+1;
                          t[fin].r[q+1,1]:=b1;
                          t[fin].r[q+1,2]:=b2;
                          t[fin].r[q+1,3]:=b3;
                       end;
                          b1:=a1;
                          b3:=a3+a2-b2;
                    if Check(st) = true then
                       begin
                          inc(fin);
                          Fill(st,fin);
                          t[fin].broi:=q+1;
                          t[fin].r[q+1,1]:=b1;
                          t[fin].r[q+1,2]:=b2;
                          t[fin].r[q+1,3]:=b3;
                       end;
                       end;

                    if a2>a[2].y then
                       begin
                          b2:=a[2].y;
                          b1:=a1+a2-b2;
                          b3:=a3;
                    if Check(st) = true then
                       begin
                          inc(fin);Fill(st,fin);
                          t[fin].broi:=q+1;
                          t[fin].r[q+1,1]:=b1;
                          t[fin].r[q+1,2]:=b2;
                          t[fin].r[q+1,3]:=b3;
                       end;
                          b1:=a1;
                          b3:=a3+a2-b2;
                    if Check(st) = true then
                       begin
                          inc(fin);Fill(st,fin);
                          t[fin].broi:=q+1;
                          t[fin].r[q+1,1]:=b1;
                          t[fin].r[q+1,2]:=b2;
                          t[fin].r[q+1,3]:=b3;
                       end;
                       end;

                    if a3>a[3].x then
                       begin
                          b3:=a[3].x;
                          b2:=a2;
                          b1:=a1+a3-b3;
                    if Check(st) = true then
                       begin
                          inc(fin);Fill(st,fin);
                          t[fin].broi:=q+1;
                          t[fin].r[q+1,1]:=b1;
                          t[fin].r[q+1,2]:=b2;
                          t[fin].r[q+1,3]:=b3;
                       end;
                          b1:=a1;
                          b2:=a2+a3-b3;
                    if Check(st) = true then
                       begin
                          inc(fin);Fill(st,fin);
                          t[fin].broi:=q+1;
                          t[fin].r[q+1,1]:=b1;
                          t[fin].r[q+1,2]:=b2;
                          t[fin].r[q+1,3]:=b3;
                       end;
                       end;
                    if a3>a[3].y then
                       begin
                          b3:=a[3].y;
                          b2:=a2;
                          b1:=a1+a3-b3;
                    if Check(st) = true then
                       begin
                          inc(fin);Fill(st,fin);
                          t[fin].broi:=q+1;
                          t[fin].r[q+1,1]:=b1;
                          t[fin].r[q+1,2]:=b2;
                          t[fin].r[q+1,3]:=b3;
                       end;
                          b1:=a1;
                          b2:=a2+a3-b3;
                    if Check(st) = true then
                       begin
                          inc(fin);Fill(st,fin);
                          t[fin].broi:=q+1;
                          t[fin].r[q+1,1]:=b1;
                          t[fin].r[q+1,2]:=b2;
                          t[fin].r[q+1,3]:=b3;
                       end;
                       end;
                 end;
           end;
        writeln(br);

      end;

end.
