#include <bits/stdc++.h>
using namespace std;
long long n;
int m, x;
char ch;
int main() {
  scanf("%I64d%c", &n, &ch);
  m = ch - 'a' + 1;
  if (n % 4 >= 1 && n % 4 <= 2)
    x = 0;
  else
    x = 2;
  if (m >= 4 && m <= 6)
    printf("%I64d", (n - 1) / 4 * 2 * 6 + (n + 1) % 2 * 6 + 6 - m + n - x);
  else
    printf("%I64d", (n - 1) / 4 * 2 * 6 + (n + 1) % 2 * 6 + m + 2 + n - x);
}
