# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import math
def solution(N):
# write your code in Python 3.6
i = int(math.sqrt(N))
while i >= 1:
if N % i == 0:
return 2 * (N // i + i)
i -= 1