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