#include <bits/stdc++.h>
using namespace std;
map<char, int> M;
int main() {
  M['f'] = 1;
  M['e'] = 2;
  M['d'] = 3;
  M['a'] = 4;
  M['b'] = 5;
  M['c'] = 6;
  string s;
  cin >> s;
  long long n = 0;
  for (int i = 0; i < s.size() - 1; i++) {
    n = n * 10 + s[i] - '0';
  }
  long long k = (n - 1) / 4;
  long long sum = 0;
  sum += k * (16);
  long long x = n % 4;
  if (x & 1)
    sum += M[s[s.size() - 1]];
  else
    sum = sum + 7 + M[s[s.size() - 1]];
  printf("%lld\n", sum);
  return 0;
}
