#include <bits/stdc++.h>
using namespace std;
int main() {
  char string[22], col;
  long long row = 0;
  fgets(string, 22, stdin);
  for (int i = 0; i < strlen(string); i++)
    if (string[i] >= '0' && string[i] <= '9')
      row = row * 10 + (string[i] - 48);
    else if (string[i] >= 'a' && string[i] <= 'f')
      col = string[i];
  long long t = 0, num;
  if (row % 2 == 0) {
    if (row % 4 != 0) {
      t = row - 1;
      num = row / 2;
      num = num - num / 2;
      num = num * 2;
      t = t + (num - 1) * 6;
    } else {
      t = row - 3;
      num = (row - 2) / 2;
      num = num - num / 2;
      num = num * 2;
      t = t + (num - 1) * 6;
    }
  } else {
    if ((row + 1) % 4 != 0) {
      t = row - 1;
      num = row / 2;
      num = num - num / 2;
      num = num * 2;
      t = t + num * 6;
    } else {
      t = row - 3;
      num = (row - 2) / 2;
      num = num - num / 2;
      num = num * 2;
      t = t + num * 6;
    }
  }
  if (col == 'f')
    t = t + 1;
  else if (col == 'e')
    t = t + 2;
  else if (col == 'd')
    t = t + 3;
  else if (col == 'a')
    t = t + 4;
  else if (col == 'b')
    t = t + 5;
  else if (col == 'c')
    t = t + 6;
  cout << t;
}
