import sys


LOOP_COUNT = 1_000_000
EXPECTED_CHECKSUM = 4_600_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 configured_target() -> str:
    return sys.argv[1] if len(sys.argv) > 1 else "omega"


def vec_string_eq_loop(limit: int, target: str) -> int:
    words = ["alpha", "omega", "delta", "omega", "sigma"]
    i = 0
    acc = 1

    while i < limit:
        current = words[i % len(words)]
        acc = acc + 7 if current == target else acc + 3
        acc = acc - 1_000_000_000 if acc > 1_000_000_000 else acc
        i += 1

    return acc


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


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