#include <bits/stdc++.h>
using namespace std;
long long n, s;
int main() {
  char tmp;
  scanf("%I64d%c", &n, &tmp);
  s = tmp - 'a';
  if (s >= 3)
    s = 6 - s;
  else
    s += 4;
  n--;
  long long ans = s;
  ans += (n / 4) * 16;
  int t = n % 4;
  if (t == 1 || t == 3) ans += 7;
  printf("%I64d\n", ans);
  return 0;
}
