def check_code(code_precedent, code_propose):
    rounds = 20

    code = code_propose
    for i in range(20):
        code = (code * 5231) % 999671
    
    if code == code_precedent:
        return 1
    return 0

for i in range(1000000):
    if check_code(773159, i) == 1:
        print(i)
        break
