#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, t = 0, j = 1, q;
  char s, i;
  cin >> n >> s;
  if (s == 'f') {
    q = 1;
  } else if (s == 'e') {
    q = 2;
  } else if (s == 'd') {
    q = 3;
  } else if (s == 'a') {
    q = 4;
  } else if (s == 'b') {
    q = 5;
  } else {
    q = 6;
  }
  if (n % 4 == 0 || n % 4 == 3) {
    t = (n - 3) + 6 * ((n / 2) - 1) + q;
  } else {
    t = (n - 1) + 6 * (n / 2) + q;
  }
  cout << t;
  return 0;
}
