using System; using System.Collections.Generic; namespace Yuki { class Program { static void Main(string[] args) { string[] ss = Console.ReadLine().Split(); int n = int.Parse(ss[0]); int d = int.Parse(ss[1]); var li = new List() { 0 }; int a = 0; int s = 0; while (true) { a += (n - s) / d; if ((n - s) % d == 0) { a -= 1; s = (-1 * (n - s) % d); } else { s = (-1 * (n - s) % d) + d; } if (li.Contains(s)) { break; } else { a += 1; li.Add(s); } } Console.WriteLine(a); } } }