#include <bits/stdc++.h>
using namespace std;
long long x, n, st[33];
string s;
int main() {
  cin >> s;
  int j = 0;
  st[0] = 1;
  for (int i = 1; i <= 20; i++) {
    st[i] = st[i - 1] * 10;
  }
  for (int i = s.size() - 2; i >= 0; i--) {
    n += ((int)(s[i]) - 48) * st[j];
    j++;
  }
  x = n;
  char seat = s[s.size() - 1];
  long long r = 0;
  if (x % 2 == 0) {
    if ((x / 2) % 2 == 0)
      r = x / 2 - 1;
    else
      r = x / 2;
  } else {
    x--;
    if ((x / 2) % 2 == 0)
      r = x / 2;
    else
      r = x / 2 - 1;
  }
  long long rr = 0;
  if (seat == 'f') rr = 1;
  if (seat == 'e') rr = 2;
  if (seat == 'd') rr = 3;
  if (seat == 'c') rr = 6;
  if (seat == 'b') rr = 5;
  if (seat == 'a') rr = 4;
  long long rrr = 0;
  if (r % 2 == 0) {
    rrr = (r / 2 * 3) + r / 2;
  } else {
    rrr = (r / 2 * 3) + r / 2 + 1;
  }
  cout << (r * 6 + rr + rrr);
  return 0;
}
