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