#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000000;
const int mod = 1000000007;
const int sze = 100005;
int main() {
  long long n;
  char ch;
  scanf("%I64d%c", &n, &ch);
  bool flag = true;
  long long term;
  if (((n + 3) % 4) == 0) {
    term = (n + 3) / 4;
  } else if (((n + 2) % 4) == 0) {
    term = (n + 2) / 4;
    flag = false;
  } else if (((n + 1) % 4) == 0) {
    term = (n + 1) / 4;
  } else if (((n) % 4) == 0) {
    term = (n) / 4;
    flag = false;
  }
  long long ans;
  ans = (term - 1) * 16;
  if (flag == false) {
    ans = ans + 7;
  }
  if (ch == 'f') {
    ans = ans + 1;
  } else if (ch == 'e') {
    ans = ans + 2;
  } else if (ch == 'd') {
    ans = ans + 3;
  } else if (ch == 'a') {
    ans = ans + 4;
  } else if (ch == 'b') {
    ans = ans + 5;
  } else {
    ans = ans + 6;
  }
  printf("%I64d\n", ans);
  return 0;
}
