/**
 * Created by IntelliJ IDEA.
 * User: m09aaa
 * Date: 28.10.2009
 * Time: 18:49:39
 * To change this template use File | Settings | File Templates.
 */
import java.util.*;
import java.io.*;

public class zamok {
       public static void main  ( String[] args ) throws Exception
    {
        Scanner in=new Scanner(new File("code.in"));
        PrintWriter out=new PrintWriter (new File("code.out"));
        int kol=0;
        int n=in.nextInt();
        int k=in.nextInt();

        int p1=in.nextInt();
        p1--;
        int v1=in.nextInt();
        int p2=in.nextInt();
        p2--;
        int v2=in.nextInt();

        for (int i=0; i<n; i++)
        {

                if (i!=p1&&i!=p2)
                {
                    int j=0;
                    while (j<k-2)
                    {
                        if (i!=p1-1&&i!=p1+1&&i!=p2-1&&i!=p2+1)
                        {
                           kol++;
                            j++;
                        }
                        else
                        {
                           if(i==p1-1||i==p1+1&&j+v1+2<=k)
                           {
                               if ((i==p2-1||i==p2+1&&j+v2+2<=k)||(i!=p2-1&&i!=p2+1))
                               {
                                   kol++;

                               }
                               else
                               {
                                   j=k;
                               }


                           }
                            else
                           {
                               if(i==p2-1||i==p2+1&&j+v2+2<=k)
                           {
                               if ((i==p1-1||i==p1+1&&j+v1+2<=k)||(i!=p1-1&&i!=p1+1))
                               {
                                   kol++;

                               }
                               else
                               {
                                   j=k;
                               }


                           }
                           }
                        } j++;
                              System.out.println();
                        System.out.println(i);
                        System.out.println(j);  System.out.println(kol);
                    }
                }

        }



        out.println(kol);
        out.close();
    }
}
