#include <bits/stdc++.h>
using namespace std;
long long n, m, i;
string s;
int main() {
  char c;
  cin >> s;
  i = 0;
  while (s[i] < 80) {
    n *= 10;
    n += s[i] - 48;
    i++;
  }
  c = s[i];
  if (n % 4 == 1) m = (n + 1) / 2;
  if (n % 4 == 2) m = (n + 2) / 2;
  if (n % 4 == 3) m = (n - 1) / 2;
  if (n % 4 == 0) m = n / 2;
  m--;
  m *= 6;
  m += n - 1;
  if (n % 4 == 0) m -= 2;
  if (n % 4 == 3) m -= 2;
  if (c == 'f') m++;
  if (c == 'e') m += 2;
  if (c == 'd') m += 3;
  if (c == 'a') m += 4;
  if (c == 'b') m += 5;
  if (c == 'c') m += 6;
  cout << m;
}
