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