#include <bits/stdc++.h>
using namespace std;
long long find_seat(char c) {
  if (c == 'a') return 4;
  if (c == 'b') return 5;
  if (c == 'c') return 6;
  if (c == 'd') return 3;
  if (c == 'e') return 2;
  if (c == 'f') return 1;
}
int main() {
  long long one, two, a, b, d, n, i, res;
  char c;
  while (scanf("%lld%c", &n, &c) != EOF) {
    one = two = false;
    a = n % 4;
    if (a == 1 || a == 2)
      one = true;
    else
      two = true;
    if (n % 2 == 0)
      b = 1;
    else
      b = 0;
    res = 0;
    if (one) {
      res = n - 1;
      d = (n - a) / 4;
      d = d * 2 * 6;
      d += b * 6;
    } else {
      res = n - 3;
      d = (n - a) / 4;
      if (n % 2 == 0) d--;
      d = d * 2 * 6;
      d += b * 6;
    }
    res += d + find_seat(c);
    printf("%lld\n", res);
  }
  return 0;
}
