#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long int number, answer;
  char temp;
  cin >> number >> temp;
  number--;
  answer = 0;
  answer = number / 4;
  answer *= 16;
  number %= 2;
  if (number == 1) {
    answer += 7;
  }
  if (temp == 'f') {
    answer += 1;
  } else if (temp == 'e') {
    answer += 2;
  } else if (temp == 'd') {
    answer += 3;
  } else if (temp == 'a') {
    answer += 4;
  } else if (temp == 'b') {
    answer += 5;
  } else if (temp == 'c') {
    answer += 6;
  }
  cout << answer << endl;
  return 0;
}
