#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
  cin >> s;
  long long size = s.size();
  char cl = s[size - 1];
  long long rn = stoll(s.substr(0, size - 1));
  long long turn = 0;
  if (rn % 2 == 0) {
    if ((rn / 2) % 2 == 0)
      turn = rn / 2;
    else
      turn = (rn / 2) + 1;
  } else {
    if (((rn + 1) / 2) % 2 == 1)
      turn = (rn + 1) / 2;
    else
      turn = (rn - 1) / 2;
  }
  long long bef = turn - 1;
  long long beftime =
      (bef * 6) + (bef % 2 == 1 ? ((bef / 2) * 3 + ((bef / 2) + 1))
                                : ((bef / 2) * 3 + ((bef / 2))));
  long long remtime =
      cl == 'f'
          ? 1
          : (cl == 'e'
                 ? 2
                 : (cl == 'd'
                        ? 3
                        : (cl == 'a' ? 4
                                     : (cl == 'b' ? 5 : (cl == 'c' ? 6 : 0)))));
  cout << beftime + remtime << endl;
  return 0;
}
