#include <bits/stdc++.h>
using namespace std;
long long n;
char sl;
int s;
int main() {
  scanf("%lld%c", &n, &sl);
  sl = sl - 'a';
  n--;
  long long answ = 16 * (n / 4);
  n = n % 4;
  if (sl >= 3) {
    answ += 5 - sl + 1;
  } else {
    answ += 3 + 1 + sl;
  }
  if (n == 1 || n == 3) answ += 7;
  cout << answ << endl;
  return 0;
}
