using static System.Math; using System; public class Hello { static void Main() { string[] line = Console.ReadLine().Trim().Split(' '); var h = long.Parse(line[0]); var a = long.Parse(line[1]); getAns(h, a); } static void getAns(long h, long a) { var c = 0; while (true) { h /= a; c++; if (h == 0) break; } Console.WriteLine((long)Pow(2, c) - 1); } }