https://www.acmicpc.net/problem/1614
#include<stdio.h>
#include <string.h>
int main() {
long n,m;
scanf("%ld %ld",&n,&m);
long num=0;
if(n==1) num+=8*m;
else if(n==5) num+=8*m+4;
else{
if(m%2==1) num+=5-n;
else num+=n-1;
num+=4*m;
}
printf("%ld",num);
}