pocky, mm = map(int, input().split()) def eat_pocky(pocky, yu): if pocky <= 0: return yu - mm yu += mm pocky -= mm*2 return eat_pocky(pocky, yu) print(eat_pocky(pocky, yu = 0))