#include <bits/stdc++.h>
using namespace std;
bool prov(char a) {
  if (a == '0' || a == '1' || a == '2' || a == '3' || a == '4' || a == '5' ||
      a == '6' || a == '7' || a == '8' || a == '9')
    return true;
  else
    return false;
}
int main() {
  string s;
  cin >> s;
  long long place = 0;
  long long i = 0;
  while (prov(s[i])) {
    place = place * 10 + s[i] - '0';
    ++i;
  }
  int time1 = 0;
  long long time2 = 0;
  if (s[s.size() - 1] == 'a')
    time1 = 4;
  else if (s[s.size() - 1] == 'b')
    time1 = 5;
  else if (s[s.size() - 1] == 'c')
    time1 = 6;
  else if (s[s.size() - 1] == 'd')
    time1 = 3;
  else if (s[s.size() - 1] == 'e')
    time1 = 2;
  else if (s[s.size() - 1] == 'f')
    time1 = 1;
  if (place % 4 == 1)
    time2 = ((place - 1) / 4) * 16;
  else if (place % 4 == 2)
    time2 = ((place - 2) / 4) * 16 + 7;
  else if (place % 4 == 3)
    time2 = ((place - 3) / 4) * 16;
  else if (place % 4 == 0)
    time2 = ((place - 4) / 4) * 16 + 7;
  cout << time2 + time1 << '\n';
}
