#include <bits/stdc++.h>
using namespace std;
char order[] = {'f', 'e', 'd', 'a', 'b', 'c'};
map<char, int> m;
int main() {
  long long n;
  char ch;
  for (int i = 0; i < 6; i++) m[order[i]] = i + 1;
  scanf("%I64d%c", &n, &ch);
  long long ans = (n - 1) / 4 * 16;
  long long k = n % 4;
  if (k == 1 || k == 3)
    ans += m[ch];
  else
    ans += 7 + m[ch];
  cout << ans << endl;
  return 0;
}
