#include <bits/stdc++.h>
long long n, cnt;
char c;
int a[200];
int main() {
  scanf("%I64d%c", &n, &c);
  a['a'] = 4, a['b'] = 5, a['c'] = 6, a['d'] = 3, a['e'] = 2, a['f'] = 1;
  if (((n + 1) >> 1) & 1)
    cnt = n - 1;
  else
    cnt = n - 3;
  n = ((n - 1) >> 2 << 1) + (n & 1 ? 0 : 1);
  printf("%I64d", n * 6 + cnt + a[c]);
  return 0;
}
