#include <bits/stdc++.h>
using namespace std;
long long n;
string s;
int seat[7] = {4, 5, 6, 3, 2, 1};
int main() {
  cin >> s;
  n = 0;
  for (int i = 0; i < s.size() - 1; i++) {
    n *= 10;
    n += s[i] - '0';
  }
  char ch = s[s.size() - 1];
  long long rs = 0;
  rs += (n - 1) / 4 * 2 * 6 + (n - 1) / 4 * 4;
  n = (n - 1) % 4 + 1;
  if (n == 1 || n == 3) {
    rs += seat[ch - 'a'];
  } else if (n == 2 || n == 4) {
    rs += 1;
    rs += 6;
    rs += seat[ch - 'a'];
  }
  cout << rs;
  return 0;
}
