LOOP_COUNT = 1_000_000
EXPECTED_CHECKSUM = 3_875_011


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 make_record() -> dict[str, list[int]]:
    return {"digits": [3, 1, 4, 1, 5, 9, 2, 6]}


def array_struct_field_loop(limit: int) -> int:
    record = make_record()
    i = 0
    acc = 11

    while i < limit:
        acc += record["digits"][i % 8]
        acc = acc - 1_000_000_000 if acc > 1_000_000_000 else acc
        i += 1

    return acc


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


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