#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, ss;
  cin >> s;
  char c = s[s.size() - 1];
  c = tolower(c);
  ss = s.substr(0, s.size() - 1);
  long long n = atoll(ss.c_str()), b = 0;
  long long q[6] = {4, 5, 6, 3, 2, 1}, h;
  if (n <= 4) {
    if (n % 4 == 1 || n % 4 == 3)
      b = q[c - 'a'];
    else
      b = q[c - 'a'] + 7;
  } else {
    if (n % 4 == 0) {
      h = ((n / 4) - 1) * 16;
    } else
      h = (n / 4) * 16;
    if (n % 4 == 1 || n % 4 == 3)
      b = q[c - 'a'] + h;
    else
      b = q[c - 'a'] + 7 + h;
  }
  printf("%I64d", b);
  return 0;
}
