#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long res = 0;
  unsigned long long x = 0;
  string s;
  cin >> s;
  for (int i = 0; i < s.length() - 1; i++) {
    x = (x * 10) + (s[i] - '0');
  }
  char c = s[s.length() - 1];
  x--;
  res = ((x / 4) * 16) + ((x % 2) * 7);
  if (c == 'f') res += 1;
  if (c == 'e') res += 2;
  if (c == 'd') res += 3;
  if (c == 'a') res += 4;
  if (c == 'b') res += 5;
  if (c == 'c') res += 6;
  cout << res << endl;
}
