#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const long long INF = 1e18 + 1;
const long long Mod = 1e9 + 7;
long long n, ans, w, e;
map<char, long long> q;
int main() {
  string s;
  cin >> s;
  q['f'] = 1;
  q['e'] = 2;
  q['d'] = 3;
  q['a'] = 4;
  q['b'] = 5;
  q['c'] = 6;
  ans += q[s[s.size() - 1]];
  for (int i = 0; i < s.size(); ++i)
    if ('1' <= s[i] && s[i] <= '9' || s[i] == '0')
      w *= 10, w += int(s[i] - '0');
  ans += (w - 1) / 4 * 12 + (w - 1) / 4 * 4;
  e = w % 4;
  if (!e) e = 4;
  if (e == 2 || e == 4) ans += 7;
  cout << ans;
  return 0;
}
