using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace finale2
{
    internal class Program
    {
        static void Main(string[] args) // 1 = =ne redar; 4 = redar; 0 = ne provereni 
        {                               // m i n mogu biti |parni parni| , neparni neparni, parni neparni, neparni parni
            string d = Console.ReadLine();            
            int n = int.Parse(d.Split()[0]);
            int m = int.Parse(d.Split()[1]);
            int b = 0;
            int[,] mat = new int[n, m];
            if (n <= 2||m<=2) { Console.WriteLine(m*n); }
            if (n > 2 && m > 2)
            {
                mat[1, 1] = 1;
                mat[1, m - 2] = 1;
                mat[n - 2, 1] = 1;
                mat[n - 2, m - 2] = 1;

                for (int i = 0; i < n; i++)
                {
                    for (int j = 0; j < m; j++)
                    {
                        mat[i, j] = 0;
                        if (i == 0 || j == 0 || i == n - 1 || j == m - 1)
                        {
                            mat[i, j] = 4;
                        }
                        if (i == 1 && j == 1 || i == 1 && j == m - 2 || j == 1 && i == n - 2 || i == n - 2 && j == m - 2) { mat[i, j] = 1; }
                        if (mat[i, j] == 0)
                        {

                            if (mat[i, j - 1] == 1 || mat[i, j + 1] == 1 || mat[i - 1, j] == 1 || mat[i + 1, j] == 1) { mat[i, j] = 4; b++; }

                        }


                    }
                    //Console.WriteLine();
                }
                for (int i = 0; i < n; i++)
                {
                    for (int j = 0; j < m; j++)
                    {
                        if (mat[i, j] == 0)
                        {
                            if (mat[i, j - 1] == 4 && mat[i, j + 1] == 4 && mat[i - 1, j] == 4 && mat[i + 1, j] == 4) { mat[i, j] = 1; }
                        }
                        //
                        if (mat[i, j] == 0)
                        {
                            if (mat[i, j - 1] == 1 || mat[i, j + 1] == 1 || mat[i - 1, j] == 1 || mat[i + 1, j] == 1) { mat[i, j] = 4; b++; }

                        }
                        if (mat[i, j] == 0)
                        {
                            mat[i, j] = 1;
                        }
                        //Console.Write(mat[i, j] + " ");
                    }
                    //Console.WriteLine();
                }
                Console.WriteLine(b + n * 2 + (m - 2) * 2);
            }
            //Console.ReadLine();
            
        }
    }
}