   class Program
   {
       static int Comb(int K, int N, int T)
       {
           if (K == 2)
               return N + 1 - Math.Max(0, 2 * (N - T));

           int C = 0;
           for (int i = 0; i <= Math.Min(N, T); ++i)
               C += Comb(K - 1, N - i, T);

           return C;
       }

       static void Main(string[] args)
       {
           int N = Convert.ToInt32(Console.ReadLine());
           int T = Convert.ToInt32(Console.ReadLine()); // here input 1000

           Console.WriteLine(Comb(4, N, T));
       }
   }