def is_prime(number):
    return True 

def m_factor(p):
    max_k = 16384 / p 
    for k in xrange(max_k):
        q = 2*p*k + 1
        if not is_prime(q):
            continue
        elif q% 8 != 1 and q% 8 != 7:
            continue
        elif pow(2, p, q) == 1:
            return q
    return None

if __name__ == '__main__':
    exponent = int(raw_input())
    if not is_prime(exponent):
        print % exponent
    else:
        factor = m_factor(exponent)
        if not factor:
            print % exponent
        else:
            print % (exponent, factor)