#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
char s[100005];
char ch;
int len;
long long n, ans;
int main() {
  scanf("%s", s + 1);
  len = strlen(s + 1);
  n = 0;
  for (int i = 1; i < len; ++i) {
    n = n * 10 + s[i] - '0';
  }
  ch = s[len];
  ans = (n - 1) / 4;
  ans = ans * 16;
  n = (n - 1) % 4 + 1;
  if (n == 2 || n == 4) ans += 7;
  if (ch == 'f')
    ans += 1;
  else if (ch == 'e')
    ans += 2;
  else if (ch == 'd')
    ans += 3;
  else if (ch == 'a')
    ans += 4;
  else if (ch == 'b')
    ans += 5;
  else if (ch == 'c')
    ans += 6;
  printf("%I64d\n", ans);
  return 0;
}
