#include <bits/stdc++.h>
int main() {
  long long int a, b, d, time = 0;
  char c;
  scanf("%lld%c", &a, &c);
  b = a / 4;
  if (a % 4 == 0) b--;
  time += b * 12;
  if (a % 4 == 2 || a % 4 == 0) {
    time += 6;
  }
  if (a % 4 == 1) time += a - 1;
  if (a % 4 == 2) time += a - 1;
  if (a % 4 == 3) {
    time += a - 3;
  }
  if (a % 4 == 0) {
    time += a - 3;
  }
  if (c == 'f')
    time += 1;
  else if (c == 'e')
    time += 2;
  else if (c == 'd')
    time += 3;
  else if (c == 'a')
    time += 4;
  else if (c == 'b')
    time += 5;
  else if (c == 'c')
    time += 6;
  printf("%lld\n", time);
  return 0;
}
