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