#include <stdint.h>
#include <stdio.h>
#include <string.h>

#define LOOP_COUNT 1000000
#define EXPECTED_CHECKSUM 4600001

static int32_t configured_loop_count(void) {
    int32_t value = LOOP_COUNT;
    if (scanf("%d", &value) != 1 || value <= 0) {
        return LOOP_COUNT;
    }
    return value;
}

static const char *configured_target(int argc, char **argv) {
    return argc > 1 ? argv[1] : "omega";
}

static int32_t string_eq_loop(int32_t limit, const char *target) {
    static const char *words[5] = {"alpha", "omega", "delta", "omega", "sigma"};
    int32_t i = 0;
    int32_t acc = 1;

    while (i < limit) {
        const char *current = words[i % 5];
        acc = strcmp(current, target) == 0 ? acc + 7 : acc + 3;
        acc = acc > 1000000000 ? acc - 1000000000 : acc;
        i = i + 1;
    }

    return acc;
}

int main(int argc, char **argv) {
    int32_t result = string_eq_loop(configured_loop_count(), configured_target(argc, argv));
    printf("%d\n", result);
    return result == EXPECTED_CHECKSUM ? 0 : 1;
}
