def METHOD_NAME(n, nv2):
    if n <= nv2:
        # lower left
        return (3*nv2 + 1) + (nv2 - n)
    elif n < (3*nv2 + 1):
        # bottom
        return (3*nv2) - (n-(nv2+1))
    elif n <= (4*nv2 + 1):
        # lower right
        return nv2 - (n-(3*nv2+1))
    elif n <= (5*nv2 + 2):
        # upper right
        return (8*nv2+3) - (n-(4*nv2+2))
    elif n < (7*nv2 + 3):
        # top
        return (7*nv2+2) - (n-(5*nv2+3))
    # upper left
    return (5*nv2+2) - (n-(7*nv2+3))