#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  long long x = 0;
  int idx = 0;
  while (str[idx] >= '0' && str[idx] <= '9') {
    x = x * 10 + (str[idx] - '0');
    idx++;
  }
  char y = str[str.size() - 1];
  long long ans = 0;
  if (x % 4 != 1 && x % 4 != 3) ans += 7;
  x--;
  ans += (x / 4) * 16;
  if (y == 'f') ans += 1;
  if (y == 'e') ans += 2;
  if (y == 'd') ans += 3;
  if (y == 'a') ans += 4;
  if (y == 'b') ans += 5;
  if (y == 'c') ans += 6;
  cout << ans;
  return 0;
}
