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