import sys from lib import * data = int(open(0).read().strip()) part2 = True def is_wall(x, y): v = x*x + 3*x + 2*x*y + y + y*y v += data bin_count = bin(v).count("1") if bin_count % 2 == 0: return False return True seen = set() poss = [(1, 1)] for step in range(51): nposs = [] for pos in poss: if pos in seen: continue seen.add(pos) if not part2 and pos == (31, 39): print(step) sys.exit(0) for (x, y) in [(-1, 0), (1, 0), (0, 1), (0, -1)]: nx, ny = pos[0] + x, pos[1] + y if nx >= 0 and ny >= 0 and not is_wall(nx, ny): nposs.append((nx, ny)) poss = nposs if part2: print(len(seen))