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