#include <bits/stdc++.h>
using namespace std;
char s[1050];
int main() {
  scanf("%s", s);
  int len = strlen(s);
  long long row = 0;
  for (int i = 0; i < len; i++) {
    if (s[i] <= '9' && s[i] >= '0') {
      row *= 10;
      row += (s[i] - '0');
    } else
      break;
  }
  long long res2 = 0;
  if (s[len - 1] == 'f') {
    res2 = 1;
  } else if (s[len - 1] == 'e') {
    res2 = 2;
  } else if (s[len - 1] == 'd') {
    res2 = 3;
  } else if (s[len - 1] == 'a') {
    res2 = 4;
  } else if (s[len - 1] == 'b') {
    res2 = 5;
  } else if (s[len - 1] == 'c') {
    res2 = 6;
  }
  long long res = 0;
  if (row % 4 == 0) {
    res += ((row - 4) / 4) * 16;
    row = 4;
    res += 7 + res2;
  } else {
    res += ((row) / 4) * 16;
    row = row % 4;
    if (row > 2) {
      row -= 2;
    }
    if (row == 1) {
      res += res2;
    } else {
      res += 7 + res2;
    }
  }
  printf("%lld\n", res);
}
