#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 2e5 + 5;
char s[25];
int solve(int x) {
  if (x >= 1 && x <= 3)
    return 3 + x;
  else
    return 6 - x + 1;
}
int main() {
  while (~scanf("%s", s)) {
    long long ans = 0;
    long long tt = 0;
    int pos;
    int n = strlen(s);
    for (int i = 0; i < n; ++i) {
      if (s[i] >= '0' && s[i] <= '9')
        tt = tt * 10 + s[i] - '0';
      else
        pos = s[i] - 'a' + 1;
    }
    ans += tt / 4 * (12 + 4);
    tt %= 4;
    if (tt == 0) {
      tt = 2;
      ans -= 16;
    } else if (tt == 3) {
      tt = 1;
    }
    ans += (tt - 1) * 7 + solve(pos);
    printf("%lld\n", ans);
  }
  return 0;
}
