#include <bits/stdc++.h>
using namespace std;
string s;
char ch;
long long num, ans;
long long p[1010];
int main() {
  p['f'] = 1;
  p['e'] = 2;
  p['d'] = 3;
  p['a'] = 4;
  p['b'] = 5;
  p['c'] = 6;
  while (cin >> s) {
    int len = s.size();
    ch = s[len - 1];
    num = 0;
    long long t, tmp = 1;
    for (int i = len - 2; i >= 0; i--) {
      t = (long long)(s[i] - '0');
      num += (t * tmp);
      tmp *= 10;
    }
    ans = 0;
    if (num <= 4) {
      if (num & 1)
        ans = p[ch];
      else
        ans = p[ch] + 1 + 6;
    } else {
      num -= 4;
      ans += 13;
      if (num % 4 == 0) {
        ans += (num / 4 - 1) * 16;
        num = (num - 1) % 4 + 1;
      } else {
        ans += (num / 4) * 16;
        num %= 4;
      }
      if (num & 1) {
        ans += (3 + p[ch]);
      } else {
        ans += (10 + p[ch]);
      }
    }
    cout << ans << endl;
  }
}
