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