#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  map<char, int> p;
  map<int, int> a;
  a[1] = 0;
  a[2] = 7;
  a[3] = 0;
  a[4] = 7;
  p['f'] = 1;
  p['e'] = 2;
  p['d'] = 3;
  p['a'] = 4;
  p['b'] = 5;
  p['c'] = 6;
  cin >> s;
  long long n = 0, k = p[s[s.size() - 1]], res, step = 1;
  s.pop_back();
  n = 0;
  for (int i = s.size() - 1; i >= 0; i--) {
    n += (((long long)s[i] - '0')) * step;
    step *= 10;
  }
  long long num;
  double mun;
  mun = ((double)n / 4) - ((long long)n / 4);
  if (mun == 0) num = 4;
  if (mun == 0.25) num = 1;
  if (mun == 0.5) num = 2;
  if (mun == 0.75) num = 3;
  res = 0;
  res += ((long long)(n - 1) / 4) * 16;
  res += a[num] + k;
  cout << res;
  return 0;
}
