#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  long long i, j;
  long long n, num, times;
  char c;
  while (cin >> s) {
    times = 0;
    c = s[s.size() - 1];
    for (num = 0, i = 0; i < s.size() - 1; i++) {
      num = num * 10 + (s[i] - '0');
    }
    long long mod, zheng;
    mod = num % 4;
    zheng = num / 4;
    if (mod == 0) {
      zheng--;
      mod = 4;
    }
    times += (zheng * 16);
    if (mod == 1 || mod == 3) {
      if (c == 'f')
        times++;
      else if (c == 'e')
        times += 2;
      else if (c == 'd')
        times += 3;
      else if (c == 'a')
        times += 4;
      else if (c == 'b')
        times += 5;
      else if (c == 'c')
        times += 6;
    } else if (mod == 2 || mod == 4) {
      times += 7;
      if (c == 'f')
        times++;
      else if (c == 'e')
        times += 2;
      else if (c == 'd')
        times += 3;
      else if (c == 'a')
        times += 4;
      else if (c == 'b')
        times += 5;
      else if (c == 'c')
        times += 6;
    }
    cout << times << endl;
  }
  return 0;
}
