#include<iostream>

using namespace std;
int main()
{

long long int a,b,r;

cin>>a>>b;

if(b>a)
{
   swap(a,b);
}

if(a>2*b)
{
   r=b*2;
   //cout<<1;
}
else
{
   if(a%2==0)
   {
      r=a;
      //cout<<2;
      
   }
   else
   {
      r=((a/2)*2)+2;
      //cout<<3;
   }
}
   cout<<r<<endl;
   //system("pause");
   return 0;
}
