#include <bits/stdc++.h>
enum {
  AT_ONCE = 4,
  TIME = 16,
};
const char MIN_CHAR = 'a';
int main(void) {
  long long n, time;
  char s;
  std::cin >> n;
  std::cin >> s;
  time = ((n - 1) / AT_ONCE) * TIME;
  n = (n - 1) % AT_ONCE;
  switch ((int)(s - MIN_CHAR)) {
    case 0:
      time += 4;
      break;
    case 1:
      time += 5;
      break;
    case 2:
      time += 6;
      break;
    case 3:
      time += 3;
      break;
    case 4:
      time += 2;
      break;
    case 5:
      time += 1;
      break;
    default:
      break;
  }
  if (n & 1) time += 7;
  std::cout << time << '\n';
  return 0;
}
