import sys


LOOP_COUNT = 1_000_000
EXPECTED_CHECKSUM = 345_000_001


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 parse_text() -> str:
    return sys.argv[1] if len(sys.argv) > 1 else "12345"


def parse_loop(limit: int, text: str) -> int:
    i = 0
    acc = 1

    while i < limit:
        acc += int(text)
        acc = acc - 1_000_000_000 if acc > 1_000_000_000 else acc
        i += 1

    return acc


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


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