#include <bits/stdc++.h>
long long n;
int a[10] = {4, 5, 6, 3, 2, 1};
char c;
signed main() {
  scanf("%lld%c", &n, &c);
  return printf("%lld\n", (((n - 1) >> 2) << 4) + (n & 1 ? 0 : 7) + a[c - 97]),
         0;
}
