var xyh = Console.ReadLine().Split(" ").Select(Int64.Parse).ToArray(); var x = xyh[0] * 1000; var y = xyh[1] * 1000; var h = xyh[2]; var items = new HashSet<(Int64, Int64, Int64)>(); items.Add((x, y, h)); var cnt = -1; while (items.Count() > 0) { cnt += 1; var nextItems = new HashSet<(Int64, Int64, Int64)>(); foreach (var (cx, cy, ch) in items) { if (cx > ch) { if (cx % 2 == 0) { nextItems.Add((cx / 2, cy, 2 * ch)); } else { nextItems.Add((cx, 2 * cy, 4 * ch)); } } if (cy > ch) { if (cy % 2 == 0) { nextItems.Add((cx, cy / 2, 2 * ch)); } else { nextItems.Add((2 * cx, cy, 4 * ch)); } } } items = nextItems; } Console.WriteLine(cnt);