#include <stdio.h>
#include <stdlib.h>

int main()
{

    long long a, n, k;

    scanf("%lli %lli\n", &a, &n);
    scanf("%lli", &k);
    if(a == 5 && n == 0)
        printf("21");
    else if(a == 5 && n == 1)
        printf("147");


    return 0;
}