#include <bits/stdc++.h>
using namespace std;
long long n, kq, luot, vt;
char s[100];
long long xet(long long x) {
  if (x == 'a') return 4;
  if (x == 'b') return 5;
  if (x == 'c') return 6;
  if (x == 'd') return 3;
  if (x == 'e') return 2;
  if (x == 'f') return 1;
}
long long tinh(char s[]) {
  long long i, l, kq;
  kq = 0;
  l = strlen(s);
  for (i = 0; i < l; i++) kq = kq * 10 + s[i] - 48;
  return kq;
}
void sol() {
  int l;
  l = strlen(s);
  vt = s[l - 1];
  s[l - 1] = 0;
  n = tinh(s);
  kq = xet(vt);
  luot = n / 4;
  if (n % 4 == 0) luot--;
  kq = kq + luot * 12 + luot * 4;
  if (n % 4 == 0 || n % 4 == 2) kq += 7;
  cout << kq << endl;
}
int main() {
  while (cin >> s) sol();
  return 0;
}
