#include <bits/stdc++.h>
using namespace std;
char str[25];
char times[6] = {4, 5, 6, 3, 2, 1};
int main() {
  scanf("%s", str);
  int len = strlen(str);
  char seat = str[len - 1];
  long long rows = 0;
  for (int i = 0; i < len - 1; i++) {
    rows = rows * 10;
    rows += str[i] - '0';
  }
  long long sec;
  if (rows % 4 != 0)
    sec = rows / 4 * 16;
  else
    sec = (rows - 1) / 4 * 16;
  int tmp = rows % 4;
  if (!tmp) tmp = 4;
  if (tmp > 2) tmp -= 2;
  sec += (tmp - 1) * 7;
  sec += times[seat - 'a'];
  printf("%I64d\n", sec);
  return 0;
}
