#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int w, num, total_row, second = 0;
  char ch;
  cin >> num >> ch;
  if (num % 4 == 0 || num % 4 == 3) {
    if (num % 4 == 0)
      total_row = num / 4;
    else
      total_row = (num / 4) + 1;
    second = (2 * (total_row - 1)) * 6;
    if (num % 4 == 0) second = second + 6 + 1;
    if (total_row - 1 > 0) second = second + 4 * (total_row - 1);
  } else {
    total_row = num / 4;
    second = (2 * total_row) * 6;
    second = second + 4 * total_row;
    if (num % 4 == 2) second = second + 6 + 1;
  }
  if (ch == 'f')
    second = second + 1;
  else if (ch == 'e')
    second = second + 2;
  else if (ch == 'd')
    second = second + 3;
  else if (ch == 'a')
    second = second + 4;
  else if (ch == 'b')
    second = second + 5;
  else if (ch == 'c')
    second = second + 6;
  cout << second;
}
