#include <bits/stdc++.h>
using namespace std;
long long x, k[6] = {4, 5, 6, 3, 2, 1};
char c;
int main() {
  scanf("%I64d%c", &x, &c);
  printf("%I64d", ((x - 1) / 4) * 16 + ((x + 1) % 2) * 7 + k[c - 'a']);
}
