#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  char ch;
  while (cin >> n >> ch) {
    long long tim = 0;
    long long sta;
    long long cis = ((n - 1) / 4) * 2 + (n + 1) % 2;
    long long loa = (n - 1) / 2;
    if (loa % 2 == 0)
      sta = 1;
    else
      sta = 3;
    tim += n - sta;
    tim += cis * 6;
    if (ch == 'f')
      tim += 1;
    else if (ch == 'e')
      tim += 2;
    else if (ch == 'd')
      tim += 3;
    else if (ch == 'a')
      tim += 4;
    else if (ch == 'b')
      tim += 5;
    else if (ch == 'c')
      tim += 6;
    cout << tim << endl;
  }
  return 0;
}
