LOOP_COUNT = 1_000_000
EXPECTED_CHECKSUM = 1_185_071


def configured_loop_count() -> int:
    try:
        value = int(input().strip())
    except (EOFError, ValueError):
        return LOOP_COUNT

    return value if value > 0 else LOOP_COUNT


def branch_loop(limit: int) -> int:
    i = 0
    acc = 7

    while i < limit:
        acc = acc - 1_000_000_000 if acc > 1_000_000_000 else acc
        acc = acc + 3 if i < 500_000 else acc + 7
        acc = acc - 1_234_567 if acc > 1_234_567 else acc + 11
        i += 1

    return acc


def main() -> int:
    result = branch_loop(configured_loop_count())
    print(result)
    return 0 if result == EXPECTED_CHECKSUM else 1


if __name__ == "__main__":
    raise SystemExit(main())
