import std.stdio;

void main(){
	auto cin = new Cin();
	
	auto NX = cin.line();
	size_t pos = 0;
	size_t ans = 0;
	
	//initial work
	ans += NX[0] + NX[1];
	pos = NX[1];
	
	foreach( i ; 0..1_000_000 ){
		writeln(ans);
		if( pos+NX[1] < NX[0]-NX[1] ){//upstair
			ans += NX[1]*2;
			pos += NX[1];
			continue;
		}
		writeln("?");
		if( pos+NX[1] > NX[0]-NX[1] ){//final add
			ans += NX[1] + NX[1] + ( NX[0]-NX[1]-pos );
			break;
		}else{
			ans += NX[1]*2;
			break;
		}
	}
	
	writeln(ans);
}

import std.stdio,std.conv,std.string;
import std.algorithm,std.array;

class Cin
{
	auto line( T = size_t )( string token = " " ){
		T[] arr;
		foreach( elm ; readln().chomp().split(token) ){
			arr ~= elm.to!T();
		}
		return arr;
	}
	/*auto rect( T = size_t )( string token = " " ){
		T[][] arr;
		arr = new
	}*/
}
