#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a, time = 0, c1, cnt = 0, sum = 0, i;
  string ch;
  cin >> ch;
  int len = ch.size();
  char str = ch[len - 1];
  for (i = len - 2; i >= 0; i--) {
    sum += (int(ch[i]) - 48) * ceil(pow(10, cnt));
    cnt++;
  }
  a = sum;
  if ((a - 1) % 4 == 0) {
    c1 = a / 4;
    time += 16 * c1;
  } else if ((a - 2) % 4 == 0) {
    c1 = a / 4;
    time += 16 * c1 + 7;
  } else if ((a - 3) % 4 == 0) {
    c1 = a / 4;
    time += 16 * c1;
  } else {
    c1 = (a - 1) / 4;
    time += 16 * c1 + 7;
  }
  if (str == 'f') time += 1;
  if (str == 'e') time += 2;
  if (str == 'd') time += 3;
  if (str == 'a') time += 4;
  if (str == 'b') time += 5;
  if (str == 'c') time += 6;
  cout << time;
  return 0;
}
